Re: NSPopUpButtonCell bindings help [TEST CASE INCLUDED]
Re: NSPopUpButtonCell bindings help [TEST CASE INCLUDED]
- Subject: Re: NSPopUpButtonCell bindings help [TEST CASE INCLUDED]
- From: "Jim Thomason" <email@hidden>
- Date: Tue, 24 Apr 2007 08:38:58 -0500
To elaborate further upon my problem, here's where to find a small
example that demonstrates the issue:
http://www.bassetsoftware.com/osx/popupcelltest.zip
And to restate the problem, in the hopes of someone offering a better
solution. Let's say I have 2 columns - petName and action. petName
will be the name of a pet ("Sparky"), and action is going to be a
numeric constant defining what action to take on him.
To make the interface more pretty, petName is run through a
transformer to produce prettier names for a pop up list ("Pet Sparky",
"Bathe Sparky", "Feed Sparky", etc.). Then a selection can be made in
the list and it's stored in the "action" field.
However - the numeric constant that defines the action is _not_
necessarily the same as the index at which it occurs, so I can't just
bind to selectedIndex. This is because new actions may be added in the
future, and it may make sense to add them to the middle of the list,
not the end.
So the transformer is slightly extended - instead of just returning
the list of action titles, it returns a dictionary consisting of
titles and numbers that correspond to actions. ({"obj" => 2, "display"
=> "Pet Sparky"}, {"obj" => 0, "display" => "Bathe Sparky"}, {"obj" =>
1", "display" => "Feed Sparky"}, etc.).
When that list is bound to content (arrangedObjects.petName, via
transformer), contentObjects (arrangedObjects.petName.obj), and
contentValues (arrangedObjects.petName.display), it all displays
properly. However, once the "action" attribute is bound to
"selectedObject" (to correspond to the number in the "obj" flag), it
crashes with an error, claiming that:
[<NSCFNumber 0x30a8b0> valueForUndefinedKey:]: this class is not key
value coding-compliant for the key display.
If I were to set all of this up using an NSPopUpButton bound to the
selection in my NSArrayController, it would work just fine. This is
also demonstrated in the test app.
I'm going to file this as a bug.
Does anyone have any suggestions for either:
1) Something I may be doing wrong.
2) A way to hack around it to get it to work, or
3) A different method to use to get the same results
?
I'm really stumped here.
Thanks,
-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