Some questions about NSArrayController



I am reading the book and at chapter 8, the RaiseMan application. If i just follow the book, i have no problem at all building the RaiseMan app, but i am not satisfied! I cannot keep my brain from asking why why why and why, how how how and how :mrgreen:
Then came to the end of the chapter where i finished challenge 1 and 2. Well, i am satisfied because i understand why and how things work by making all the connections manually (without binding).
I didn’t want to give up so i read the binding document from Apple, after a long time reading, i confused myself even more. And i am stuck right here with the controller objects, NSObjectController, NSArrayController…Here is what i think about them, please correct me:

-For the NSArrayController, it “holds” an array and have some functions to work with the array. In the Figure 8.4, it says “[color=#800000]contentArray=employees[/color]”. That made me thought the NSArrayController has an instance variable called contentArray, is it true? Well well, i guess not but i am not sure :frowning:. Here is what i read on Apple online document “[color=#0000FF]NSObjectController exposes a single binding for content called contentObject[/color]”. That made me thought, no, the contentArray is not an instance variable of the class NSArrayController, but then what does it mean by “a binding”? Or is it just the way they call it in the Interface Builder? (Content Array)

-Then from the NSArrayController, we get the content array back by calling -arrangedObjects: , is it correct? But one thing i am sure, the -arrangedObject: return an array. In the Figure 8.9, the Value is bound to the array controller, and the controller key is arrangedObjects, model key path is personName. I wonder if there is any other way to bind the value of a column of a table view directly to an array without having to use NSArrayController.

-The NSArrayController also manages what are selected in a table view, is it correct?

And many more questions but i cannot formulate them right now …

Thank in advanced,



Bindings can be very confusing, and the documentation is pretty tricky in places (particularly in finding the list of bindings available for a specific class).

Yes, there is a binding on NSArrayController called contentArray. Here’s the NSArrayController Bindings reference. Bindings are different from properties and there is usually not much overlap between the two. Not directly, anyway. In the case of the contentArray binding, you will be able to find the same value in the content property.

The method is called arrangedObjects (no colon). Unfortunately the best explanation I can provide is: “this is just how cell based table view bindings work.” They are a little magical, and you just have to get accustomed to the pattern. View-based table views, which we use in the Core Data chapter (Ch.11), are much more straightforward, bindings-wise. But very different from cell-based table views.

Right, using the selectionIndexes binding, which in this case overlaps with the property of the same name.