Re: Binding to title of NSButtonCell in a table view
Re: Binding to title of NSButtonCell in a table view
- Subject: Re: Binding to title of NSButtonCell in a table view
- From: Quincey Morris <email@hidden>
- Date: Sun, 18 Jul 2010 01:33:41 -0700
On Jul 18, 2010, at 00:41, Gideon King wrote:
> Thanks for the reply - that sounds similar to what I tried before where I hooked in to the dataCellForTableColumn and willDisplayCell methods, but they are not updated when the underlying data is changed, which would presumably mean that somewhere I would have to set up KVO for each value that was displayed, so that I can force an update of the cell, and remove the KVO if a row is removed from the underlying data - something I don't need to do when it is bound through the table column. Am I understanding this correctly?
I think this is unnecessarily complicated. I'd first be inclined to try a much simpler approach. Make the data model property that the table column's "value" is bound to be KVO-dependent on the data model title property. You can likely do this just by defining a +keyPathsForValueAffecting<MyValueProperty> method that returns the title property key, in the relevant data model class.
That means that if either the value changes or the title changes, a KVO notification is sent to the table column, which causes the corresponding row to be redisplayed. That in turn causes the data cell to be prepared, and so your dataCellForTableColumn delegate method would be invoked, allowing you to transfer the correct title to the button cell.
I'd seriously try to avoid any solution that involves manually adding KVO observers and removing them later.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden