views:

463

answers:

2

I'm trying to decide which path to take for developing my Snow Leopard app. First, I should preface with the obvious differences:

NSTableView can have multiple columns of data for representing different parts of the same "element" of data (a row) where NSCollectionView can display a grid of data as well, but every row+column combo is its own element. For my purposes, assume I'm dealing with a single column.

  1. As far as I can tell, NSCollectionView items are NSViews which all must be of the same dimensions. Also, unlike NSTableView, collectionview items are copied to the NSCollectionView instead of being provided as needed by a dataSource (I'm uncertain about this, please correct me if I'm wrong).

  2. NSTableView uses NSCells if you decide to customize the display of rows. As NSCell isn't an NSResponder, how does one handle events (if I wanted to add some sort of accessory to the cell, like how the Arrows in iTunes work (although, iTunes is Carbon). I've seen some NSCell subclasses in IB which appear to be equivalents of their NSControl brethren, but what if I want to have MySweetView objects in an NSCell?).

  3. Both seem to work about the same with respects to Bindings, correct?

  4. Finally, NSCollectionView appears to play nicely with animation of its elements (for re-arranging items, or filtering them for example). Can NSTableView do this with its rows?

Anything else I should consider?

+2  A: 
  1. The difference here is that in a table view, every row is one item, and the columns show different aspects (properties) of that item. In a collection view, every row-column intersection is one item.
  2. I haven't done this, but try implementing tableView:didClickTableColumn: in your table view delegate. That method is new in 10.6. You would need to get [NSApp currentEvent], and probably pass it to a method in the column's cell.
  3. With a table view, you bind the column; you don't bind the view (not to provide content, anyway; you do bind the view for things like selection indexes). With a collection view, there are no columns (see #1), so you always bind the view.
  4. No.
Peter Hosey
For number 1, I mentioned that in my preface. My concern is how the data is provided to the table vs CV. The CV's `NSCollectionViewItem` has a `representedObject` and also a `view` property, but does the CV ask a delegate for this info, or does the NSCVI act as a controller responsible for this or…? The documentation is seriously lacking for this class!
jbrennan
Looking at the class reference, it appears that you provide the collection view with your model objects in its `content`, and it will create CVIs for them from its prototype. Each model object is then the `representedObject` of a CVI.
Peter Hosey
+1  A: 

FWIW, NSTableView is a very old part of the AppKit, and it's a bit crufty.

If you're new to the platform, I'd recommend getting your head around NSCollectionView first.

NSResponder