I am trying to run some MacOS programs and have some problems understanding how bindings work with NSPopupButton. I'm interested in binding to the NSDictionaryController (I don't think I need an intermediate NSArrayController, but if this is the best way, I'm open to it).
I created a controller object that has the 'db' property, which has the 'species' property, which is NSMutableDictionary. The "species" dictionary has an identifier for keys and species objects for values. View objects have a description property. In InterfaceBuilder, I created MyController, NSDictionaryController, and NSPopupButton. I would like to pop up the Species.descriptions popup. When selected, I need access to the corresponding identifier.
I installed NSDictionaryController to associate the "Content Dictionary" with MyController with the Key Path pattern "db.species". With NSPopupButton so far, I have bound the "Content Values" to the NSDictionaryController with the controller key "builtObjects" and the Path Key Path set to "value.description".
This seems to work by filling out the list. My main question is the best way to connect the choice. Ideally, I would like to connect the selection to an NSDictionaryController so that I can use the NSDictionaryController to access the selection. One reason for this is that I can connect other controls to the NSDictionaryController to see the current selection. If not, should I connect to a property in MyController or something else? Just look for best practices. I would like it to be through Interface Builder mechanisms so that I can easily reuse the model and design of the controller in another application with a different view.
Update using Brian's answer as a guide:
NSPopupButton: associate content with NSDictionaryController-> orderedObjects-> value.description
bind content objects to NSDictionaryController-> assemblyObjects-> key
bind selected pointer to NSDictionaryController-> selectionIndex
bind NSDictionaryController-> db.species
Everything works. I can capture an object from the controller using the value [[[selected selectedbjects] lastObject]]. I think this is in an array of selected objects with keys, pairs of values.