0

I want to have the index of the current selected Dictionary of an NSCollectionView.

I have this code but it always returns "0".

- (IBAction)selectItem:(id)sender {
    NSInteger index = [[CollectionView subviews]  indexOfObject:self.representedObject];
    NSLog(@"%ld", (long)index);
}

I don't know what I am doing wrong.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • A NScollectionView is a panel that displays all items in a collection. What do you expect "IndexOf" to represent? If you expect the current selection, it looks like there is a "selection" item that you can use to get the currently selected item. See https://stackoverflow.com/questions/12814028/get-the-index-of-view-from-which-a-button-was-clicked-in-a-nscollectionview?rq=1 – BenPen Sep 08 '16 at 22:04
  • @BenPen okey, thats what i mean. So i am going to try that link tommorow – Damian Van de Kauter Sep 09 '16 at 05:21

0 Answers0