On Feb 2, 2012, at 10:50 PM, Devarshi Kulshreshtha wrote:

> I have an array of dictionary which contains two keys- firstName
> and lastName and their values, eg.
> 
> firstName/ lastName
> 
> Steve/ Jobs
> Andre/ Agassi
> Christiano/ Ronaldo
> 
> User interface consists of a pop up button and a text field.
> 
> I am displaying first name of users in pop up button. I am able to show
> first name of the user selected in pop button in the text field by using
> following bindings:
> 
> NSArrayController
> 
> Content Array - AppDelegate - myArray
> 
> NSPopUpButton
> 
> content - Array Controller - arrangedObjects - firstName

This is almost never what you want. Bind content to arrangedObjects without a 
controller key. Then bind contentValues to Array Controller - arrangedObjects - 
firstName.

> selected value - AppDelegate - selectionValue

I would not bind this but instead bind selectedObject. "Value" always refers to 
the displayed value, and in your case that is always the first name. To 
accomplish this, you can bind contentObjects to Array Controller - 
arrangedObjects - lastName.

> NSTextField
> 
> Value - AppDelegate - selectionValue

This will now work as you expect. As a matter of design, it would actually be 
better if your "selectionValue" was the dictionary object that contains the 
names, which is really the logical selection object. You can keep the above 
bindings except unbind contentObjects and change the NSTextField binding to 
AppDelegate - selectionValue.lastName .

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to