• 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
NSPopUPButton and selectedTag binding seems to give me index instead
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPopUPButton and selectedTag binding seems to give me index instead


  • Subject: NSPopUPButton and selectedTag binding seems to give me index instead
  • From: Stuart Malin <email@hidden>
  • Date: Thu, 5 Mar 2009 11:35:17 -1000

I have a NSPopUpButton that is driven by bindings. I establish (programmatically) a binding between the NSPopUpButtom instance's "selectedTag" property and an NSTreeController that contains objects that have a property that should correspond with the available tag values. This does not seem to work. It appears that the binding is instead working with the popup button's index value. Symptoms and circumstance:

1) I changed the binding for the popup button's contentValues to refer to the tag property of the bound collection (rather than the title), and sure enough the proper tag values are displayed, so the menu items do have tag values.

2) When I change the popup button selection, the value in the object bound to the "selectedTag" is changed -- problem is: the value that is set is the index value, not the tag value.

The code...

First, what works: I drive the content and contentValues from an object that I construct which is an indexed accessor KVC (read-only) compliant with a backing store array of NSMenuItem items. When I initialize the collection, the menu items are initialized with a title. I also set the tag property. The bindings for these to the NSPopUpButton instance is done programmatically:

	[twitterUpdateFrequencyPopupButton bind:@"content"
					toObject:updateItems
					withKeyPath:@"UpdateFrequencyMenuItems"
					options:nil];
	[twitterUpdateFrequencyPopupButton bind:@"contentValues"
					toObject:updateItems
					withKeyPath:@"UpdateFrequencyMenuItems.tag"
					options:nil];

"updateItems" is the ordered collection of NSMenuItems; its indexed accessor property is "UpdateFrequencyMenuItems"

Here's what doesn't work, the binding for the selected tag value:

	[twitterUpdateFrequencyPopupButton bind:@"selectedTag"
					toObject:twitterAccountsArrayController
					withKeyPath:@"selection.frequency"
					options:nil];


"twitterAccountsArrayController" is an NSArrayController. The objects it manages have a "frequency" property.


When this is run, I receive no messages in the console about anything bad or wrong.

I've tried searching the usual places and with Marc Liyange's Mac Developer Search Engine for matters related to NSPopUpButton and selectedTag, but haven't found anything germane. So I post here.







_______________________________________________

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: NSPopUPButton and selectedTag binding seems to give me index instead
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: Question about the Foundation Framework
  • Next by Date: mouseUp event for NSSlider
  • Previous by thread: Re: Thread usage : Main thread interrupting secondary thread
  • Next by thread: Re: NSPopUPButton and selectedTag binding seems to give me index instead
  • Index(es):
    • Date
    • Thread