• 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: How to show last name of user in text field whose first name is selected in popup button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to show last name of user in text field whose first name is selected in popup button


  • Subject: Re: How to show last name of user in text field whose first name is selected in popup button
  • From: Keary Suska <email@hidden>
  • Date: Fri, 03 Feb 2012 14:49:41 -0700

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 (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: 
 >How to show last name of user in text field whose first name is selected in popup button (From: Devarshi Kulshreshtha <email@hidden>)

  • Prev by Date: Re: MPMoviePlayerController, full-screen, and rotation
  • Next by Date: NSColorWell / NSColorPanel
  • Previous by thread: How to show last name of user in text field whose first name is selected in popup button
  • Next by thread: MPMoviePlayerController, full-screen, and rotation
  • Index(es):
    • Date
    • Thread