Re: NSPopUpButtonCell bindings help
Re: NSPopUpButtonCell bindings help
- Subject: Re: NSPopUpButtonCell bindings help
- From: Keary Suska <email@hidden>
- Date: Tue, 24 Apr 2007 13:36:23 -0600
- Thread-topic: NSPopUpButtonCell bindings help
on 4/24/07 12:03 PM, email@hidden purportedly said:
>> 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.
You're missing the point here--the "repeats" object must exist in the
content/Objects array (i.e. content array, but contentObjects array instead
if bound). If your test project is made from real code, this will never be
the case. I.e. the "repeats" object must be one of the "val" objects, and
not just equivalent, it must be the exact same 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.
You're right--not always, just in certain cases. However, using your test
project, I get the exact same error when adding an external popupbutton and
binding selectObject to selection.bar. So what you describe above can't be
the case if your test project is an accurate model.
Your best bet is likely to have a particular class and arraycontroller to
manage the popup content. The trick then is making sure that every "repeats"
object is matching object from this special class. Throw in a transformer
for the contentValues binding to get the special display that you want.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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