Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

viewForTableColumn is not run (but objectValueForTableColumn is)

Whilst trying to create a view based table it keeps calling the objectValueForTableColumn function instead of the viewForTableColumn.

I have set the table view to "view based" in its settings. But still I cannot make it call the correct function. I've looked at the implementation of apples example (tableviewplayground) and at some points even copy pasted the IB and functions, still no progress.

The relevant code:

// Should run
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row 
{    
    return nil;
}

// Gets run
-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
    return nil;
}

Two pictures, not sure how helpful they are but still. http://imgur.com/a/ix34Q

like image 323
jontelang Avatar asked Sep 23 '12 10:09

jontelang


1 Answers

A few things to check:

  • Does your NSTableView have its delegate set to the class that implements the NSTableViewDelegate protocol? (I ask because tableView:viewForTableColumn:row: is a delegate method whereas the tableView:objectValueForTableColumn:row: is a data source method.)

  • Are there any bindings that are set in IB? (You mention that you copied the nib from an existing project.) Check mainly for bindings to the NSTableView content binding and to the provided view's subviews (usually the text field.)

  • Do you implement the numberOfRowsInTableView: method from the NSTableViewDataSource protocol and does it return a nonzero integer?

Finally, you might have a look at the Table View Programming Guide chapter on "Populating View-Based Table Views Programmatically" in the documentation.

like image 123
FluffulousChimp Avatar answered Sep 30 '22 20:09

FluffulousChimp