Question

I have a table that's using bindings to get table data. I'm also using willDisplayCell to customize the specific cell when it's being displayed. My question is, how do I get the value of the cell that's being referred-to in the willDisplayCell method? I don't want to query the controller object, since I'm using bindings and not a dataSource. Is there something in the NSTableColumn or NSTableView that I have to call to get the value?

Was it helpful?

Solution

There's nothing wrong with mixing the data source and bindings approaches. In fact, the documentation mentions the two can be mixed for greater control in complicated situations. It's done all the time, so don't think you're doing something wrong.

Also, point of order: the -tableView:willDisplayCell:forTableColumn:row: method is part of the NSTableViewDelegate protcol, not the NSTableViewDataSource protocol, so it's even less "dirty" than you think. :-)

The correct way in this situation is to create an outlet to your array controller (so you can message it) and ask it for the object in its -arrangedObjects whose index matches the requested row. Any other way and you're fighting the framework.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top