Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my cell based NSTableView calling viewForTableColumn?

I have a view controller that's the delegate for 2 tables, a view based table and a cell based table. The cell based table is calling viewForTableColumn when it should be calling objectValueForTableColumn. I made doubly sure it was a cell based table in the interface builder.

like image 478
ssj Avatar asked Apr 19 '12 19:04

ssj


2 Answers

If the delegate of the NSTableView implements the method tableView:viewForTableColumn:row:, the NSTableView automatically switches to view based. You'll have to make different delegates for the 2 table views

like image 71
IluTov Avatar answered Sep 21 '22 18:09

IluTov


View-Based Table Views and Cell-Based Table Views do not mix, you can either have two different delegates or you can turn the cell bases table to a view based table and then use the following code in tableView:viewForTableColumn:row: to make it look like a cell-based table:

NSTableCellView *cell = [tableView makeViewWithIdentifier:@"textFieldCell" owner:self];

where textFieldCell is the identifier of the cell. Then you set the string you want to appear in the cell using this code:

[[cell textField] setStringValue:desiredString];

at the end of the method return the variable cell

like image 30
Matthew Muscat Avatar answered Sep 20 '22 18:09

Matthew Muscat