Re: Menu binding displaying serialized NSDictionary rather than specified field
Re: Menu binding displaying serialized NSDictionary rather than specified field
- Subject: Re: Menu binding displaying serialized NSDictionary rather than specified field
- From: chaitanya pandit <email@hidden>
- Date: Mon, 13 Oct 2008 14:51:15 +0530
Shouldn't it be:
{id: 1, name: @"Front"}
{id: 2, name: @"Sports"}
{id: 3, name: @"Opinion"}
{id: 4, name: @"Living"}
{id: 4, name: @"Calendar"}
note the '@'
Chaitanya
On 13-Oct-08, at 2:29 PM, Ken Tozier wrote:
Hi
I have a popup in a table cell I'm trying to bind, programatically,
to a simple array of NSDictionaries and want to display a single
field from each dictionary as the menu text. What I'm getting
instead is the entire dictionary serialized as a menu item. Here's
how I'm doing the binding
Here's an example of the array of dictionaries I'm trying to bind to:
{id: 1, name: "Front"}
{id: 2, name: "Sports"}
{id: 3, name: "Opinion"}
{id: 4, name: "Living"}
{id: 4, name: "Calendar"}
Here;s what I want to appear in the menu:
Front
Sports
Opinion
Living
Calendar
Here's what I'm actually seeing in the menu:
{id: 1, name: "Front"}
{id: 2, name: "Sports"}
{id: 3, name: "Opinion"}
{id: 4, name: "Living"}
{id: 4, name: "Calendar"}
Here's how I'm setting up the bindings:
masterCell = [[NSPopUpButtonCell alloc] init];
[masterCell setBordered: NO];
[masterCell setBezeled: NO];
masterColumn = [[NSTableColumn alloc] initWithIdentifier: @"master"];
[masterColumn setDataCell: masterCell];
[masterColumn bind: @"content" toObject: self withKeyPath:
@"properties.masters" options: nil];
[masterColumn bind: @"contentValues" toObject: self withKeyPath:
@"properties.masters.name" options: nil];
// NOTE: I'm really not sure how to specify the selection as the
value resides in another object
[masterColumn bind: @"selectedValue" toObject: self withKeyPath:
@"pages.master" options: nil];
I read the docs here: http://developer.apple.com/documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSPopUpButtonCell.html#/
/apple_ref/doc/uid/NSPopUpButtonCell-DontLinkElementID_801 but after
hours of futzing, I'm still not able to get it working
And as best as I can figure, it should work, so why am I getting
these serialized dictionaries?
Thanks for any help
_______________________________________________
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
_______________________________________________
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