Differences between NSTableView and NSCollectionView

I am trying to decide which way to develop my Snow Leopard application. First, I must point out the obvious differences:

NSTableView can have multiple data columns to represent different parts of the same data "element" (row), where NSCollectionView can also display a data grid, but each combination of columns and columns is its own element. For my purposes, suppose I am dealing with a single column.

  • As far as I can tell, NSCollectionView are NSCollectionView elements that should be the same size. In addition, unlike NSTableView collection elements are copied to the NSCollectionView instead of being provided as needed by the dataSource (I'm not sure about this, please correct me if I am wrong).

  • NSTableView uses NSCell if you decide to customize the display of rows. Since NSCell not an NSResponder , how to handle events (if I wanted to add some kind of accessory to a cell, for example, how arrows work in iTunes (although iTunes is Carbon). Some NSCell subclasses in IB that seem to be equivalent to their NSControl marriages, but what if I want to have MySweetView objects in NSCell ?).

  • Both seem to work roughly the same with respect to Bindings, right?

  • Finally, NSCollectionView seems to play great with animating its elements (for re-arranging elements or filtering them, for example). Can NSTableView do this with its own rows?

Anything else I should consider?

+2
source share
2 answers
  • The difference is that in the table view, each row represents one element, and the columns show different aspects (properties) of this element. In a collection view, each intersection of column columns is one element.
  • I did not do this, but try to implement tableView:didClickTableColumn: in your table view delegate. This method is new in 10.6. You will need to get [NSApp currentEvent] and probably pass it to the method in the column cell.
  • With a table view, you bind a column; you donโ€™t bind the view (donโ€™t provide the content, anyway, you bind the view to things like selection indices). There are no columns with the collection view (see # 1), so you always bind the view.
  • Not.
+3
source

FWIW, NSTableView is a very old part of AppKit, and it's a little cool.

If you are new to the platform, I would recommend wrapping around an NSCollectionView first.

+2
source

Source: https://habr.com/ru/post/912076/


All Articles