• 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
Binding a NSArrayController to a NSPopupButtonn & NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding a NSArrayController to a NSPopupButtonn & NSTextField


  • Subject: Binding a NSArrayController to a NSPopupButtonn & NSTextField
  • From: Eric Gorr <email@hidden>
  • Date: Fri, 15 Feb 2013 07:41:37 -0500

What I want to accomplish seems like it should be fairly straightforward. I have placed a sample project at https://github.com/ericgorr/arraycontrollerbindings.

I have a NSArrayController filled with an array of NSDictionaries.

[[self controller] addObject:@{ @"name" : @"itemA", @"part" : @"partA" }];
[[self controller] addObject:@{ @"name" : @"itemB", @"part" : @"partB" }];
[[self controller] addObject:@{ @"name" : @"itemC", @"part" : @"partC" }];

I am populating a NSPopupButton with the items in this array based on the 'name' key. This is easily accomplished with the following bindings.

Content Array binding -
	bound to: Array Controller
	controller key: arrangedObjects

Content Values binding
	bound to: array controller
	controller key: arrangedObjects
	model key path: name

I would then like to populate a NSTextField with the text in the 'part' key based on the current selection of the NSPopupButton. I have setup the following binding:

Value binding
	bound to: array controller
	controller key: selection
	model key path: part

With these bindings alone, the text field does display 'partC'.

However, if I change the value of the NSPopupMenu, what the text field shows does not change.

I thought this would simply be a matter of setting up the 'Selected Object' binding on the NSPopupButton with the controller key 'selection', but that isn't working. I end up with the proxy object in my menu for some strange reason (providing the reason why would be a bonus).

What am I missing to make this work?




_______________________________________________

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

  • Follow-Ups:
    • Re: Binding a NSArrayController to a NSPopupButtonn & NSTextField
      • From: Keary Suska <email@hidden>
  • Prev by Date: Observing changes user did in Print&Scan tab in System Preferences.
  • Next by Date: Re: How to use NSManagedObjectContext, NSManagedObjectModel, NSEntityDescription, NSManagedObject
  • Previous by thread: Observing changes user did in Print&Scan tab in System Preferences.
  • Next by thread: Re: Binding a NSArrayController to a NSPopupButtonn & NSTextField
  • Index(es):
    • Date
    • Thread