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: Sat, 17 Jul 2010 23:41:52 -0700
On Jul 17, 2010, at 23:21, Gideon King wrote:
> [[resultsTableView tableColumnWithIdentifier:@"startDateColumnIdentifier"] bind:@"title" toObject:resultsArrayController withKeyPath:@"arrangedObjects.topic.taskStartStringForPanel" options:nil];
>
> If the cell for the column is an NSTextFieldCell, and the binding is "value", this displays the string successfully, but when I change to an NSButtonCell and try to bind "title", I get the error message.
That's because you're binding the table column, not the data cell. Table columns don't have a "title" binding.
In the simple case, binding the table column's "value" binding to a value works because the default behavior transfers the bound value to the data cell each time it's used. (As you know, the data cell for the column is re-used for each row that's displayed.) Clearly, that can't work for a button cell's "title" binding.
You're going to have to use one of the various data cell preparation methods to set up the correct title every time the button cell is used. This set-up *could* re-bind its "title" binding every time, but there's no point -- it's simpler just to set the desired title string directly.
There are two points worth noting here:
1. You can't use a set-once-and-forget approach to binding the button cell title, because the button cell is re-used for every row.
2. For the normal "value" binding, it *seems* that you can use a set-once-and-forget approach, but that works because the table column has internal behavior to transfer this binding value to the data cell every time it's used.
_______________________________________________
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