One Quickie


Reacting to TableView selection changes when using bindings (Bindings->NSTableView)
You're using bindings to handle the tableview, but now you have some code that needs to do something when the selection changes (in my case I was disabling a sheet's OK button if the selection in two tableviews was the same). The way to track that change is to add yourself as an observer of the array controller that's driving the tableview, and then do the work in the observeValueForKeyPath: method. Register your observer like this:
    [searchArrayController addObserver: self
                           forKeyPath: @"selectionIndexes"
                           options: NSKeyValueObservingOptionNew
                           context: NULL];
So now self's observeValue method will get invoked when selectionIndexes changes in the array controller.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com