I have an NSTableView, the content of which is bound to an arrayController using a filterPredicate. The tableView is view-based, so its delegate is set to an object that has the
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
method. I’m getting odd behavior, which may be related to my observation that this method is being called even when the controller’s number of arrangedObjects is 0. Moreover, each time the method is called, the number of rows it asks for is the total number of objects in the array controller’s content (as opposed to arrangedObjects). It think it may be because of this that when I set the objectValue of the cellView requested using
cellView.objectValue = [arrayController arrangedObjects] objectAtIndex:row];
that it is often the wrong one. Any ideas?
Well, I still can’t explain why the view was behaving as it was, but I did manage to get things to behave correctly, doing the following:
providing each tableCellView as follows (where BILSelectableRoundedTableCellView happens to be a subclass of NSTableCellView):
Finally, using a datasource that implements the following:
The use of the later seems contrary to the documentation out there, but is necessary to get things to work properly. Interestingly, the other datasource method (numberOfRowsInTableView) is not called when using bindings, although it is called when i’m not using bindings.