I' ve a NSCollectionViewItem
subclass, called MyItem
used as item of my NSCollectionView
. I need to enumerate all the item in my collection view to set the delegate for each item with this code:
NSUInteger categoryNumber = [self.collectionView.content count];
for (NSUInteger cont = 0;cont < categoryNumber;cont++)
{
MyItem *categoryItem = (MyItem*)[self.collectionView itemAtIndex:cont];
categoryItem.interactionDelegate = self;
}
Using the debugger I saw that this code works as I aspect and in each iteration the MyItem
points to a different object each time. The problem is that when I use mouseDown
event on my MyItem
class I receive the same object whatever item i click on the NSCollectionView
. It seems that the collection view use only one class (the cell template instance?). Anyone have an idea of what is going on? thanks