NSPopUpButton Bindings question
NSPopUpButton Bindings question
- Subject: NSPopUpButton Bindings question
- From: Chris Backas <email@hidden>
- Date: Wed, 21 Sep 2005 12:03:54 -0400
Greetings all,
I'm writing a new UI for an internal company program, and I figured it
would be a good opportunity for me to finally learn Cocoa bindings. I
seem to have gotten the hang of some aspects, but I'm having a heck of
a time getting an NSPopUpButton to bind its selected item. First, let
me explain what I have so far.
I have a class called stationTemplateEditorController which for the
sake of this discussion has one KeyValue property, called 'templates',
which returns an NSArray.
In my NIB, I've got an instance of this class instantiated and I
created an NSObjectController and set its content outlet to that
instance. I told the NSObjectController that its Object Class Name was
stationTemplateEditorController and it has one Key: templates.
Then I created an NSArrayController, and bound its ContentArray
property to Controller Key:selection and Model Path Key:templates of
the previously created Object Controller. I've set the Array
Controller's Object Class Name to StationTemplateClass, and added all
the properties of that class (There are several, but in the interest of
starting simple they're all Strings)
Finally, I have an NSPopUpButton in my UI. I bound its content to the
ArrayController's arrangedObjects, I bound its contentView to the
ArrayController's arrangedObjects with a Model Path of stationType.
This works find, the Popup button is correctly populated from my model,
and the displayed values in the list are correct. The problem comes in
with changing the selection. I've got some NSTextFields in my UI that I
bound to the Array Controller's selection, with appropriate Model Key
Paths into the StationTemplateClass objects that it contains. They all
display 100% correctly for the initially selected object in the
NSPopUpButton, but they don't change when I change the button's
selection.
Now, clearly this is because I've not bound one of the button's
selected* properties to anything, but this is the problem. I can't
figure out WHICH of them to bind to WHAT. From what I've read in the
docs, it looks like NSArrayController should keep track of the
selection. So I tried binding selectedObject to the Controller's
selection. No dice. I tried binding selectedIndex to the controller's
selectionIndex. This results in mysterious console messages like so:
2005-09-21 11:22:45.125 TemplateViewer[11440] *** -[NSCFType
setState:]: selector not recognized
2005-09-21 11:22:45.149 TemplateViewer[11440] *** -[NSCFType
setState:]: selector not recognized
I can't seem to find any examples of doing quite what i'm doing, they
almost always involve a table view. I'm SURE that I'm missing something
simple that an experienced Bindings user could point out in 30 seconds,
but I'm stumped for now =)
Thanks in advance!
Chris Backas
_______________________________________________
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