Simon Fell > Its just code > Cocoa Bindings
Sunday, October 15, 2006
Cocoa (via Interface Builder) supports some nifty data binding support, for example i was able to easily bind the list of items in a pop-up button to an array of strings that's stored in the user defaults. But I can seem to find the right magic set of options to correctly bind this list to a TableView in a preferences window so that i can edit/add/remove items from the list. Using NSArrayController seems to get me the closest, I bind the ContentArray in the Array Controller to the use defaults property that has my array. Then bind the column in the table to the ArrayController. This gets close, the existing list of values shows in the table column (yay!), but if i edit one of the values, then i see this error in the console, "Error setting value for key path of object myStringValue (from bound object <NSTableColumn) : [<NSCFString setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key ." Which i'm sure makes sense to someone, but not me. I also can't work out how to let you click in the list to create a new entry. It seems like this is the sort of plumbing that it's suposed to be making easy, but I can't get it to work, grrhhhh, I'm getting to the point where I'll skip the binding support and go 'old school' just so I can move onto something more interesting (like gettings Sparkle hooked up).