NSTableView with more than one UI element in NSCell (like Transmission)

622 views Asked by At

How would I make an NSCell with more than one UI element in it and display it in an NSTableView? For NSCells with a single value I could implement tableView:objectValueForTableColumn:row: but I don't know how to do this for NSCells with more than one. At the moment I have an NSView in an NSCollectionView and all the elements are bound to an NSArrayController. But I'd rather have an NSTableView or similar.

2

There are 2 answers

2
Dave DeLong On BEST ANSWER

You return the primary value in the tableView:objectValueForTableColumn:row: method, and then set up the cell further in tableView:willDisplayCell:forTableColumn:row:.

Either that, or you create a custom NSCell subclass that can customize itself based on the objectValue that you give it.

0
Dominic On

I've switched to JAListView for table and outline views in my Mac apps: https://github.com/joshaber/JAListView

It has the advantage of using NSViews for table items instead of NSCells, allowing for greater freedom in implementing your design.

There's a few other alternatives out there too trying to solve similar gaps in NSTableView and its subclasses: http://groups.google.com/group/cocoa-unbound/browse_thread/thread/87b2a1b5725eac05