Simon Fell > Its just code > Cocoa Bindings

Wednesday, October 25, 2006

I continue to explore these, I'm fairly impressed so far, when it works, its really nice, to explore what you can do with it, I started rebuilding my blogging client in cocoa (the blogging client UI is largely a binding problem), so far its gone fairly well. My main problem came when I tried to use it in conjunction with NSUserDefaults, and my model has an object model defined by me, but these objects can't be stored in NSUserDefaults directly (it only supports primatives + arrays + dictionaries). I ened up putting some code in my controller to go between my objects and user defaults supportable stuff, there's probably an easier way to do it though, seems like it should be doable in a pretty generic maner through reflection and KVC.

My last remaining problem is in place editing of a single column table, e.g.

The table column is bound to an NSArrayController, the controller is bound to a NSUserDefaults property that contain an array of strings. The table correctly shows the list, but if you allow editing, you get errors when it tries to propogate the change. Other than this one issue, its going well, almost the entire UI for writing/editing posts and for managing weblog configuration and categories is wired up, and i've written remarkedly little code so far.