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 |