Vikas Bansal
Vikas Bansal

Reputation: 11730

How to remove all items from NSCollectionView?

I am trying to remove all the items that user has added in NSCollectionView by removing all items from NSMutableArray. It's not working.

I just need to Refresh/Reload by Clear/Remove all items of the NSCollectionView

Upvotes: 2

Views: 769

Answers (2)

Vikas Bansal
Vikas Bansal

Reputation: 11730

//remove/clear all items from NSCollectionView

 for (int i = 0; i < [[arrayController arrangedObjects] count]; i++) {
        [arrayController removeObjectAtArrangedObjectIndex:i];
        i--;
    }

Upvotes: 1

Pradumna Patil
Pradumna Patil

Reputation: 2220

Try this

NSIndexSet* selectedIndexSet = [_lablesCollectionView selectionIndexes];
NSUInteger index = [selectedIndexSet firstIndex] ;
NSLog(@"index is %d", index);
[lablesArray removeObjectsAtArrangedObjectIndexes:selectedIndexSet];

Hope it helps.

Upvotes: 1

Related Questions