I\'d like to use the NSFetchedResultsControllerRelegate in a CollectionViewController. Therefore I just changed the method for the TableViewController for the CollectionView
Combining a fetched results controller with a collection view is a bit tricky. The problem is explained in
If you're looking for how to get around the
NSInternalInconsistencyExceptionruntime exception withUICollectionView, I have an example on GitHub detailing how to queue updates from the NSFetchedResultsControllerDelegate.The problem is that the existing
UITableViewclass usesbeginUpdatesandendUpdatesto submit batches to the table view.UICollectionViewhas a newperformBatchUpdates:method, which takes a block parameter to update the collection view. That's sexy, but it doesn't work well with the existing paradigm for NSFetchedResultsController.
Fortunately, that article also provides a sample implementation:
From the README:
This is an example of how to use the new
UICollectionViewwithNSFetchedResultsController. The trick is to queue the updates made through theNSFetchedResultsControllerDelegateuntil the controller finishes its updates.UICollectionViewdoesn't have the samebeginUpdatesandendUpdatesthatUITableViewhas to let it work easily withNSFetchedResultsController, so you have to queue them or you get internal consistency runtime exceptions.