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
2008-11-24 16:37:33
Thanks, I'm not using bindings for this portion, so that's just the delegate I was looking for. A+
Rich Catalano
2008-11-24 17:34:53
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
2009-09-16 05:50:17