Deleting objects in a collection view not working right

| | August 11, 2015

I have my query which returns 20 objects at a time, which is working correctly. But for testing edge cases I have only 7 objects in my table. So my query returns 7 objects. My threshold is 20 at a time.

So the 20 objects (boxes) are drawn on screen. The data loads and fills the 7 boxes. How do I get rid of 8 to 20 and update the scollview?

I have this to delete when the 7 objects are done loading:

- (void) endOfResultsReached:(NSInteger) index
    [self.collectionView performBatchUpdates:^{
        NSIndexPath *indexPath =[NSIndexPath indexPathForRow:index inSection:1];
        [self.collectionView deleteItemsAtIndexPaths:[NSArray arrayWithObject:indexPath]];

    } completion:^(BOOL finished) {


So in above index comes in at 7 (as objects 0 to 6 fill there boxes). But the delete deletes everything that isn’t visible on the screen. Why?


Leave a Reply