Re: NSPopUpButtonCell bindings help
Re: NSPopUpButtonCell bindings help
- Subject: Re: NSPopUpButtonCell bindings help
- From: "Jim Thomason" <email@hidden>
- Date: Tue, 24 Apr 2007 13:03:37 -0500
> content - arrangedObjects.nextDate (running through a transformer to
> get an array of dictionaries with two keys - val and display)
> contentObjects - arrangedObjects.nextDate.val
> contentValues - arrangedObjects.nextDate.display
> selectedObject - arrangedObjects.repeats
A common issue that seems to be the source of most popupbutton binding
issues, is that the object acquired from the selectedObject binding must
exist in the object array acquired from the content or contentObjects
binding. That is, the *exact same object*, not just an equivalent object.
In this case, content contains an array of dictionaries with two keys
(display & val).
contentObjects is an array of NSNumbers (the objects in the val slot
in the dictionary)
contentValues is an array of NSStrings (the objects in the display
slot in the dictionary)
repeats is an NSNumber.
I confirmed with my little test app that the NSNumbers being used are
always the exact same object, which makes sense for an immutable
object.
Additionally, the selectedObject object must be KVC compliant for the key
used in a contentValues binding, as you have noticed. If you meet the first
criteria, the second usually follows. In your case, bindings expect
"repeats" to be a "nextDate".
This doesn't appear to always be the case. With an NSPopUpButton bound
to selection.repeats, it doesn't need to be KVC compliant for the key
in contentValues. It's only when I use an NSPopUpButtonCell in a table
that's bound to arrangedObjects.repeats that it does need to be KVC
compliant for the key in contentValues. Again, my little test case can
demonstrate this:
http://www.bassetsoftwarecom/osx/popupcelltest.zip
I still think this is a bindings bug - why should it require the key
for arrangedObjects but not for selection?
And while it is true that if I rewire my objects to use one that's KVC
compliant for the key in contentValues, I can't quite do it yet. This
is because I don't have access to the value that's displayed at a
particular slot - it only exists inside the array created by the
transformer, and the transformer is transforming a different value
(nextDate instead of repeats).
If this is what I need to do to get it to work, I'll need to think a
bit more about how to re-wire to be able to access the key.
-Jim....
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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