I would like the delete the selected cels in the UICollectionView
.
@property (weak, nonatomic) IBOutlet UICollectionView *cardTable;
@property (strong, nonatomic) NSMutableArray *cardTableArry; // of Card and datamodel
you can get the paths of them using as an array
NSArray *indexPaths = [[self cardTable] indexPathsForSelectedItems];
you can't [[self cardTable] removeObjectsAtIndexes: indexPaths];
as you need a NSIndexSet
.
is there a way to convert the NSArray *indexPaths
to a NSIndexSet
ore do i need to do somting intierly difrend to get what i wand
I would like to convert the array in a NSIndexSet
[[self cardTableArry] deleteItemsAtIndexPaths: [[self cardTable] indexPathsForSelectedItems]];
The solution:
- (void) removeCardsFromTable: (NSArray *) indexPaths {
NSMutableArray *cards = [[NSMutableArray alloc] init];
for (NSInteger selectedLoop = 0; selectedLoop < 3; selectedLoop++) {
NSIndexPath *card = [indexPaths objectAtIndex: selectedLoop];
[cards addObject: [[self cardTable] objectAtIndex: [card item]]];
}
for (NSInteger selectedLoop = 0; selectedLoop < 3; selectedLoop++) {
[[self cardTable] removeObject: [cards objectAtIndex: selectedLoop]];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.