tags:

views:

711

answers:

1

I've got a table with checkbox-style cells, and I can't figure out how to get these buttons to take on the titles that they're supposed to. Should the data source be an array of strings? An array of dictionaries (string/boolean)? An array of NSButtonCells? None of these seem to work =/

+2  A: 

NSButtonCell uses integer values (as NSNumbers) as its data source:

NSMixedState = -1,
NSOffState   = 0,
NSOnState    = 1

That doesn't help you with the title of course, you have to set that separately. If you're using bindings, NSButtonCell defines a title binding you can bind to an array of strings. Otherwise, you can use the NSTableView delegate method - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex to set the title for each row.

Marc Charbonneau
Thanks, I'm not using bindings for this portion, so that's just the delegate I was looking for. A+
Rich Catalano
You can’t bind the title in the button cell; it doesn’t work (or at least I haven't found a way to make it work).
Chris Suter