Re: PopupButtonCell in a TableView column
Re: PopupButtonCell in a TableView column
- Subject: Re: PopupButtonCell in a TableView column
- From: Matt Neuburg <email@hidden>
- Date: Thu, 04 Mar 2010 13:09:43 -0800
- Thread-topic: PopupButtonCell in a TableView column
On Thu, 04 Mar 2010 11:03:49 -0800, Lynn Barton <email@hidden> said:
>With a model entity of (let's say) MyData and an array controller of
MyDataArrayController, and two properties myIntProperty and myStringProperty,
the tableview works perfectly without the popup menu. In this case, the first
column has a text cell and a number formatter, and the column is bound to
MyDataArrayController.arrangedObjects.myIntProperty. The second column is bound
to MyDataArrayController.arrangedObjects.myStringProperty.
>
>Then I created another array controller, MyMenuArrayController (super is
NSArrayController), which builds a fixed array of 3 NSStrings. That array
becomes the arrangedObjects property of the controller.
You can't bind to an array of strings because a string is not key
value-coding compliant. You should bind to an array of NSMutableDictionary,
even if these dictionaries each contain just one key-value pair. There's a
reason why this is the default.
>After removing the number formatter, and placing an NSPopupButtonCell in the
first column of the table, I have tried many different bindings, and none of
them worked. I always get the console error message " [<NSTableColumn
0x200083e20> valueForUndefinedKey:]: this class is not key value
coding-compliant for the key value."
This is a frequently asked question. It would help if Apple would use
quotation marks in this error message. This means you have asked something
for the value of a key called @"value", but the thing you are asking for
this key doesn't have a key by that name. (If, as I said above, it's a
string, it doesn't have *any* keys; that's why, if you aren't going to
supply your own key-value compliant class, you want to use a dictionary,
which does have keys.)
In short, bindings depend upon KVC (key-value coding). It might be helpful
for you to review the documentation on KVC.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
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