I am trying to wrap my head around the reloadItemsAtIndexPaths UICollectionView method.
I have an array of objects called objectsArray. When the user scrolls to the bottom of my collection view, I select the next group of objects from the backend and add it to the Array object by calling [objectsArray addObjectsFromArray: objects]; After that, I call [self.collectionView reloadData], which, as I know, is expensive.
I would like to optimize the code below, but I get an assertion error when calling reloadItemsAtIndexPaths.
if (self.searchPage == 0) {
parseObjectsArray = [[NSMutableArray alloc] initWithArray:relevantDeals];
[self.collectionView reloadData];
} else {
NSMutableArray *indexPaths = [[NSMutableArray alloc] init];
for (int i = 0; i < [relevantDeals count]; i++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForItem:i inSection:0];
[indexPaths addObject:indexPath];
}
[parseObjectsArray addObjectsFromArray:relevantDeals];
[self.collectionView reloadItemsAtIndexPaths:indexPaths];
}
Error: * Approval error in - [UICollectionView _endItemAnimations], / SourceCache / UIKit / UIKit-2903.2 / UICollectionView.m: 3716
Any help / advice is appreciated.
Thanks!