On 2010 Feb 18, at 13:30, Quincey Morris wrote:
> you could simply have your window controller provide an array property with
> version strings for the current OS (along with a KVO dependency to keep the
> property in sync with the current OS), and bind the popup content to that
> array.
>
> However, I'd suggest that perhaps you're asking the wrong question -- there
> might be a deeper data model design issue.
Quincey's answer is excellent, and abstract. Let me give you a concrete
example from one of my projects. Presumably your table is bound to an array
controller whose contentSet or contentArray is bound to a collection of Foo
objects in your data model.
Table Column Bindings for "OS Version" column:
Content:
Bind to: FooArrayController
Controller Key: arrangedObjects
Model Key Path: osVersionChoices
Content Values:
Bind to: FooArrayController
Controller Key: arrangedObjects
Model Key Path: osVersionChoices.osVersionDisplayName
Selected Object:
Bind to: FooArrayController
Controller Key: arrangedObjects
Model Key Path: osVersion
In your data model,
@interface Foo {
}
@property (retain) NSString* osVersion ; // Could also be NSNumber
/* Returns an array of NSStrings (or NSNumbers) */
- (NSArray*)osVersionChoices ;
...
@end
And finally, and I forgot who it was who gave me this invaluable tip, you
implement a category on NSString (or NSNumber) which defines
-osVersionDisplayName. You can do your localization or transforming in here.
I've never been able to get a Value Transformer to work in an NSTableColumn
binding. But the category works every time.
Note that -osVersionChoices and of course -osVersionDisplay name are readonly.
No problem. If you table is not editable, -osVersion can be readonly too.
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]