Menu binding displaying serialized NSDictionary rather than specified field
Menu binding displaying serialized NSDictionary rather than specified field
- Subject: Menu binding displaying serialized NSDictionary rather than specified field
- From: Ken Tozier <email@hidden>
- Date: Mon, 13 Oct 2008 04:59:05 -0400
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