Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.

Crash occurs if user deletes a photo in Photos app, and goes back into app. #51

Open
DavidStummer opened this issue Jul 4, 2016 · 0 comments

Comments

@DavidStummer
Copy link

Error:

Fatal Exception: NSInternalInconsistencyException
attempt to delete and reload the same index path (<NSIndexPath: 0xc000000000200016> {length = 2, path = 0 - 1})

code i used to fix (in - (void)photoLibraryDidChange:(PHChange *)changeInstance):

NSIndexSet *changedIndexes = [collectionChanges changedIndexes]; // make sure that a changed index hasn't been deleted in the meantime // (for example by a user deleting a photo in Photos app) NSMutableIndexSet *changedIndexes2 = [NSMutableIndexSet new]; [changedIndexes enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) { [removedIndexes enumerateIndexesUsingBlock:^(NSUInteger idx2, BOOL * _Nonnull stop2) { if (idx != idx2) { [changedIndexes2 addIndex:idx]; } }]; }]; if ([changedIndexes2 count]) { [collectionView reloadItemsAtIndexPaths:[changedIndexes2 aapl_indexPathsFromIndexesWithSection:0]]; }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant