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. https://i.stack.imgur.com/8CKCx.jpg
A few things to check:
Does your
NSTableViewhave itsdelegateset to the class thatimplements the
NSTableViewDelegateprotocol? (I ask becausetableView:viewForTableColumn:row:is a delegate method whereas thetableView: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
NSTableViewcontent binding and to the provided view’ssubviews (usually the text field.)
Do you implement the
numberOfRowsInTableView:method from theNSTableViewDataSourceprotocol and does it return a nonzerointeger?
Finally, you might have a look at the Table View Programming Guide chapter on “Populating View-Based Table Views Programmatically” in the documentation.