• 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 binding value/selected problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPopUpButton binding value/selected problem


  • Subject: NSPopUpButton binding value/selected problem
  • From: Trygve Inda <email@hidden>
  • Date: Thu, 17 Oct 2013 11:35:10 -0700
  • Thread-topic: NSPopUpButton binding value/selected problem

I have an NSArray Controller that manages an array of Dictionaries that
contain two NSString objects "Name" and "Identifier"

The Name field is shown in an NSTable and is user editable while the
Identifier is generated when the dictionary is created and is used to
reference the object by the app (since the user can change the name field).

I want to show a popup with a list of the names,

I bind the popup:

Content (myArray.arrangedObjects)
Content Objects (myArray.arrangedObjects.Identifier)
Content Values (myArray.arrangedObjects.Name)

This works great. I create dictionaries and end up with my array holding
something like:

{
    Identifier: 12345
    Name: "Untitled"
}
{
    Identifier: 67897
    Name: "Hello"
}
{
    Identifier: 35795
    Name: "Testing"
}

The popup shows 3 entries: Untitled, Hello, Testing

All seems great.

Then I set the popup to the second entry "Hello".

If I then change the text "Hello" to "Hello Again" (or anything else) in the
NSTable, the popup resets its selection to the first index. It seems to want
to store the selection by the string of the name and when that string
changes, it tries to find the new index, and can't, so it resets to index
one.

How can I tie the selected index to the Identifier (67897 instead of
"Hello") since the Identifier will not change?

I don't want to bind the Selected Index to a selection in the NSArray
Controller, but do want to be able to change the Name in the Dictionary
without the popup menu trying to maintain a selection based on the name...
The name in the popup should simply change to whatever the new naem at that
index is.



_______________________________________________

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 binding value/selected problem
      • From: Jerry Krinock <email@hidden>
    • Re: NSPopUpButton binding value/selected problem
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: "No options" constant
  • Next by Date: Re: "No options" constant
  • Previous by thread: Re: "No options" constant
  • Next by thread: Re: NSPopUpButton binding value/selected problem
  • Index(es):
    • Date
    • Thread