Re: NSPopUpButton Binding Frustration
Re: NSPopUpButton Binding Frustration
- Subject: Re: NSPopUpButton Binding Frustration
- From: Ken Thomases <email@hidden>
- Date: Mon, 30 Jan 2012 14:15:33 -0600
On Jan 30, 2012, at 1:12 PM, Seth Willits wrote:
> On Jan 30, 2012, at 8:26 AM, Ken Thomases wrote:
>
>> content -> fileTypes
>> contentValues -> fileTypes.displayName
>> contentObjects -> fileTypes.uti
>> selectedObject -> fileType
>
>
> [...] The documentation could use another couple sentences to make this clearer.
Agreed. After I replied, I went searching for where this is documented. As is often the case, I only found it in release notes, those for the AppKit for 10.4:
http://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKitOlderNotes.html
> - Selection widgets (NSPopUpButton/NSPopUpButtonCell and NSMatrix) now offer a contentObjects binding in addition to the content and contentValues bindings (the contentObjects binding becomes available only if content is bound). This allows you to bind the content of the widget to an array (content binding), the displayed values to a dependent array (contentValues binding - which needs to use a key path that is an extension to the one of the content binding), and the "represented" objects to be handled through the selectedObject/selectedObjects bindings to another depdendent array (contentObjects - which also needs to use a key path that is an extension to the one of the content binding). For example, if you have an array with dictionaries (that can be bound to a controller through the "selection.dictionaries" key) which each have values for a key "displayName" and a key "representedObject", you can bind content of a pop-up button to "selection.dictionaries", contentValues to "selection.dictionaries.displayName" and contentObjects to "selection.dictionaries.representedObject" - the selectedObject will then operate on the "representedObject" values, while the pop-up displays the "displayName" values in the user interface. Of course, if you do not use the contentObjects binding, the represented objects are still the values in the array to which content is bound.
So, there you go. Nice and clear, just impossible to find. ;)
> Thanks Ken.
You're welcome.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden