Bindings & Table Data Sources
So, I once again attempted to make use of Cocoa Bindings this morning, and once again ended up frustrated and annoyed. My goal this time was to get column sorting working in Cocoalicious, and to have the current sort state persist through the defaults even after the app is quit. I hated writing the code for that in PodWorks, and thought that I could save myself a lot of trouble by binding my table view’s sort descriptors to the shared user defaults controller. I got this working using an NSUnarchiveFromData value transformer (since the NSSortDescriptor objects need to be archived as data to be stored in the defaults system), and was quite pleased until I discovered that the post table no longer displayed any data.
A little investigation revealed why: the table’s “objectValueForTableColumn:” data source method appears not to be getting called. I looked in Interface Builder to see if the data source was still properly connected to the table, and it looked to have been unset, so I re-connected it. After rebuilding and launching again, though, the data source was still not getting called.
I have to say I’m a bit confused by this. Is this expected behavior? Does using any binding on a table view, even one unrelated to the table’s actual data, actually cause the data source to be ignored, or am I doing something wrong (or is this a bug)? I really hope so, because I’d rather not be forced to convert all of my table management code to use bindings yet.