Skip navigation.
 
mlRe: NSCollectionView subclassing
FROM : Ron Lue-Sang
DATE : Fri Nov 09 19:07:29 2007

On Nov 9, 2007, at 9:01 AM, <email_removed> wrote:

> Date: Fri, 9 Nov 2007 16:33:38 +0100
> From: public.<email_removed>
> Subject: NSCollectionView subclassing
> To: <email_removed>
> Message-ID: <<email_removed>>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
> Hi list,
>
> 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

NSCollectionViewItem *item = [[NSCollectionViewItem alloc] init];
[item setRepresentedObject:passedInRepresentedObject];
[item setView:someNewViewThatWillDisplayDataFromTheRepresentedObject];
return item;

File a documentation bug, there's nothing in collectionView or 
collectionViewItem that is named layoutView.


-----------------------------
Ronzilla
Core Bindings/Cocoa Builder/Interface Data

Related mailsAuthorDate
mlNSCollectionView subclassing public.web Nov 9, 16:33
mlRe: NSCollectionView subclassing Ron Lue-Sang Nov 9, 19:07