NSArrayController - bind to user preferences?

I have 3 NSArrayController’s, each one is bound to a table column which is editable in my application’s preferences window.

Based on the data in these arrays, I need to update my user interface (adding these entries to an NSComboBox, enabling or disabling some check boxes, etc.).

These arrays then need to be saved and loaded with the application.

Would binding somehow in interface builder to NSUserPreferences work, or should I just handle this in the applications start/exit code?

I’m also not quite sure how to call an action in my application when the lists change to update the user interface.

Well to update, I just ended up binding the NSArrayControllers to user preferences. That way there is no saving/reading of values.

Now in my application I am just trying to figure out how to iterate through the array values like I would the prior applescript list, and I still need a notification in my application for when the lists change to refresh the interface. Then I should be good to go!

Maybe it will help you to read “Cocoa Bindings Programming Topics”, which can be found in the OSX 10.9 docset of XCode.

There are several ways to notify when a value of a table view cell changes.

¢ implement a delegate method of the table cell like textDidEndEditing or selectionDidChange and post a notification with NSNotification (not to be confused with NSUserNotification). In case of a view based table view a simple IBAction can be used.

¢ Alternatively If the data source of the table view uses a custom class instead of a NSMutableDictionary override the setter of the specific property and notify from there

¢ implement a key-value observer for the particular variable or key path of the NSArrayController


Since ASOC is single threaded, you hardly need to use bindings in order to keep track of changes to your arrays when the window with your tableviews? are up and running.

I think the best method to implement are selectionDidChange and didEndEditing for your tableViews.

However, if you want to use bindings, then I recommend the Collection View Programming Guide Quick start for collection Views since the setup of bindings from the collection view, is almost identical as to how you would do it with a table view. But! Before you use it, you should understand how the different UI elements are assembled, and not do like I did, stuff them into the collection view, and not into the separate view that represents the grid.

(Which is why I removed the reference from my post above.)


I came by this command line argument a while a go for logging bindings. It has helped me some when I have been stuck. It is more informative than stack traces, and quells at least some thrown exceptions due to binding errors.