• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Menu binding displaying serialized NSDictionary rather than specified field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Menu binding displaying serialized NSDictionary rather than specified field


  • Subject: Re: Menu binding displaying serialized NSDictionary rather than specified field
  • From: Ken Tozier <email@hidden>
  • Date: Mon, 13 Oct 2008 05:37:08 -0400

That was just an email typo, the real code is correct.

On Oct 13, 2008, at 5:21 AM, chaitanya pandit wrote:

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


References: 
 >Menu binding displaying serialized NSDictionary rather than specified field (From: Ken Tozier <email@hidden>)
 >Re: Menu binding displaying serialized NSDictionary rather than specified field (From: chaitanya pandit <email@hidden>)

  • Prev by Date: Re: Menu binding displaying serialized NSDictionary rather than specified field
  • Next by Date: Re: NSCollectionView - getting notified of selection change?
  • Previous by thread: Re: Menu binding displaying serialized NSDictionary rather than specified field
  • Next by thread: right-click on a title-bar of borderless-window
  • Index(es):
    • Date
    • Thread