6

I've understood the fly-weight approach of cell-based NSTableView and I think I understand the differences with NSCollectionView.Differences between (cell-based) NSTableView and NSCollectionView

However, a bit less obvious is the differences between view-based NSTableView and NSCollectionView.

With NSCollectionView's flexibility in displaying its items (i.e. in a grid layout) which could emulate a tableView's list (a grid with maximum one column) and excluding personnal preferences, why would someone choose (View-based) NSTableView over NSCollectionView?

Community
  • 1
  • 1
  • 1
    Because NSCollectionViews are one of the most fiddly things ever introduced in Cocoa? (That's only my opinion, of course.) – Extra Savoir-Faire Mar 30 '12 at 18:44
  • 1
    One pro argument for collections views over view-based tableviews for me is that insert/remove animations come out-of-the box and even work, when binding the collection view to a controller.. – bijan May 05 '12 at 16:41

1 Answers1

8

Update: (Recycling of views is implemented since El Capitan)

NSCollectionView doesn't use view recycling. This means that a view will be created for every single collection view item, regardless of whether the view is on screen or not. This can wreck your performance with large data sets. A view based NSTableView uses view recycling and is very efficient, as it recycles a limited number of cells instead of creating new ones for every item. Not to mention that NSCollectionView is overall a poorly written and poorly documented class.

Sentry.co
  • 5,355
  • 43
  • 38
indragie
  • 18,002
  • 16
  • 95
  • 164
  • 1
    @ indragie: Confused: According to apple's doc here: https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSCollectionViewDataSource_protocol/index.html#//apple_ref/doc/uid/TP40016649-CH1-SW6, views are being recycled in NSCollectionView, and they would, won't they? Agree that `NSCollectionView` is poorly written though. :) – Sunil Chauhan Jun 10 '16 at 13:57
  • Just write a NSCollectionView for a OS X 10.10 compatible application. And I would like to vote "NSCollectionView is overall a poorly written and poorly documented class". However, NSCollectionView of OSX10.11 may worth a try, it looks much better now. – Adison Aug 23 '16 at 10:22
  • 6
    Recycling of views is implemented since El Capitan – Lothar Oct 05 '17 at 05:12