Doing something wrong with bindings, can't find out what

I've a mutable array that holds instances of a model object. That model object has several properties one being "name". I have no problems initialising or populating the mutable array.

I've a window with a drawer. I added a table to the drawer, the idea being that the drawer would use the table to display several instances of the model object.

I added an nsarraycontroller to the xib of the window that has a drawer. In the Array Controller Properties I've set the Object Controller to be an instance of the model class. On the Array Controller Bindings I set the Controller Content to point to the File Owner and set the Model Key Path to the name of the array.

On the table, I bind the content to the Array Controller, the Controller Key to arrangedObjects and Model Key Path to name.

My problem is that although the mutable array has been properly initialised and populated I can't see a single entry on the table on the drawer. Am I missing something here?

Answers


Two possibilities:

First: you might have bound the wrong thing (your description here is a bit ambiguous). Bind each table column's "values" to the array controller's @"arrangedObjects.propertyName" (like arrangedObjects.firstName for the First Name column, etc.). There are alternative ways to bind the whole table, but you probably aren't binding the column's values, just the table's content.

Second: it's also possible the accessor to your model object isn't KVO compliant. Make sure proper KVO notifications wrap your setter accessor for your model array. If you've @synthesize'd it, all should be well. If you've hand-coded your accessors, all might not be well. :-)


I assume you bound the tablecells table columns to the arraycontroller? I don't think Interface Builder will let you do anything else. Otherwise, it sounds like you have it configured properly.

I would recommend ibtool for troubleshooting these kinds of problems. It's a command line tool that does a text dump. You can inspect bindings in a more compact form than using the GUI in Interface Builder.


Need Your Help

From MinGW static library (.a) to Visual Studio static library (.lib)

visual-studio static mingw

I'm trying to use xlsLib for creating Excel spreadsheets from a C++ application.