UICollectionView + NSFetchedResultsController + performBatchUpdates

I tested the proposed solution here to update the UICollectionView from NSFetcherResultsController . But I have some problems.

My UICollectionView shows the hierarchy (sorted by name) of folders and documents. By clicking on the document, open it and clicking on the folder, click on the new controller with UICollectionView (expand).

User can copy / cut / paste documents and folders.

Example problem:

 Root | ---"B" |---"A" 

If I copy form β€œA” to β€œRoot”, β€œA” is pasted into β€œRoot” and β€œB” is updated (elmentsCount--). The problem is that β€œB” gets the animation to insert, and β€œA” gets the animation to update.

I placed two message blocks in the block that I use to perform a batch update:

 case NSFetchedResultsChangeInsert: NSLog(@"INSERTING at pos : %d", ((NSIndexPath *)obj).item); [self.libraryCollectionBrowser insertItemsAtIndexPaths:@[obj]]; break; case NSFetchedResultsChangeUpdate: NSLog(@"UPDATING at pos : %d", ((NSIndexPath *)obj).item); [self.libraryCollectionBrowser reloadItemsAtIndexPaths:@[obj]]; break; 

Journal:

 INSERTING at pos : 0 UPDATING at pos : 0 

What is the right way to do this?

+4
source share

All Articles