• 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: bindings question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bindings question


  • Subject: Re: bindings question
  • From: Lee Morgan <email@hidden>
  • Date: Fri, 20 May 2005 16:31:10 -0400

On May 20, 2005, at 3:08 PM, Benjámin Salánki wrote:

Hi, I have the following situation:

I have a CoreData application, model done. In IB I create the NSArrayController for my array, create a table and set it up to display the values, added an add and remove button, array management works like a charm. In a separate window i have a popup button which contains the name values of the array, perfect. Now what for the life of it i can't do is to display another column's values from the table in a text field next to the popup and change the value if the popup's selected item changes. Can this be done in IB using bindings or should I just go back to Xcode and code the part, which would take me 5 minutes at most.

Any ideas?

OK, If I understand you correctly you have a pop up menu which displays the array's name values, and you want a text field to display another value of the currently selected entity in the pop up menu?

If this is the case then yes you can do it with bindings - and yes you'll have to write some code. Sadly pop-up menu's don't set the selection of the NSArrayController, and if you use the entities as content for the pop-up menu then you can't bind the selectedObject of the pop up menu to Shared User's Defaults (for some reason it won't NSManagedObject as a value?)

So...In my AppDelegate I added a NSManagedObject "currentlySelectedItem" variable - write accessors if you wish.

Then the way I bind the pop-up menu like so...
content: 
bind to: NSArrayController
Controllery Key: arrangedObjects

contentValues:
bind to: NSArrayController
Controller Key: arrangedObjects
Model Key Path: displayName

selectedObject:
bind to: AppDelegate
Model Key Path: currentlySelectedItem

Then I bind the text field like this...
value:
bind to: AppDelegate
Model Key Path: currentlySelectedItem.otherValue


Hope that helps,
Lee
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >bindings question (From: Benjámin Salánki <email@hidden>)

  • Prev by Date: Re: bindings question
  • Next by Date: Actually centering a window
  • Previous by thread: Re: bindings question
  • Next by thread: hyper-link style button
  • Index(es):
    • Date
    • Thread