I am trying to subclass NSCollectionView using -
(NSCollectionViewItem *)newItemForRepresentedObject:(id)object.
The doc says in this method we have to set the view, representedObject
and layoutView for the new item. I assume layoutView is the leopard-
seeds name for collectionView. But I still don't understand how to set
it in NSCollectionViewItem because there is no setCollectionView
method. I also did [self setItemPrototype:newItem] and I get an
infinite loop.
Thanks.
As the name implies, the collectionView maintains a collection of
views. The views come from the collectionViewItems (one to one). Each
collectionViewItem has a view associated with it.
If you let the default machinery run, for every model object you feed
the collection view (its content), you'll get a copy of the
itemPrototype., including an "copy" of the collectionViewItem's view.
Your newItemForRepresentedObject should do something like