I'm deleting a CollectionViewCell with this code:
- (void)deleteProjects:(NSNotification *)notification {
// Get the current project
NSString *currentProject = [[MyManager sharedManager] projectForDeletion];
[_objects removeObject:currentProject];
[_projectsCollectionView performBatchUpdates:^{
NSArray *selectedItemsIndexPaths = [_projectsCollectionView indexPathsForSelectedItems];
// Now delete the items from the collection view.
[_projectsCollectionView deleteItemsAtIndexPaths:selectedItemsIndexPaths];
} completion:nil];
// Subtract 1 from editedProjects
editedProjects = editedProjects - 1;
// Set deletedProject
deletedProject = currentProject;
// Delete the associated subjects if any
[self deleteAssociatedSubjects];
// Save the new objects
[[NSUserDefaults standardUserDefaults] setObject:_objects forKey:@"myProjects"];
}
For the user to delete an item:
- enter edit mode
- select cell
- select a red x that'll appear
- it'll get deleted
Now if the user selects 2 cells, he/she will get notified that only 1 is editable at a time - but the items still get's "selected" - causing the delete to delete the item that couldn't be edited instead of the original one. How can I fix this?
Method for selecting:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath: (NSIndexPath *)indexPath
{
}
Thanks!