Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Crash with deleted photos in iTunes library #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions QBImagePicker/QBAssetsViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,11 @@ - (void)photoLibraryDidChange:(PHChange *)changeInstance

NSIndexSet *changedIndexes = [collectionChanges changedIndexes];
if ([changedIndexes count]) {
[self.collectionView reloadItemsAtIndexPaths:[changedIndexes qb_indexPathsFromIndexesWithSection:0]];
}
// We need to remove the removed images, since reloading them will cause a crash
// "uncaught ObjC exception, reason: attempt to delete and reload the same index path"
NSMutableIndexSet *changedWithoutRemovalsIndexes = [changedIndexes mutableCopy];
[changedWithoutRemovalsIndexes removeIndexes:removedIndexes];
[self.collectionView reloadItemsAtIndexPaths:[changedWithoutRemovalsIndexes qb_indexPathsFromIndexesWithSection:0]];
} completion:NULL];
}

Expand Down