Skip to content

Instantly share code, notes, and snippets.

View aureliensibiril's full-sized avatar

Aurélien Sibiril aureliensibiril

View GitHub Profile
### Keybase proof
I hereby claim:
* I am aureliensibiril on github.
* I am aureliensibiril (https://keybase.io/aureliensibiril) on keybase.
* I have a public key ASDCpdpHa1xn-oz8QBMPvVsWKdm2isjh1Apt4eelx53pywo
To claim this, I am signing this object:
@aureliensibiril
aureliensibiril / gist:6c00da64f8962b14aaa4d7f3bc15b8fc
Created June 30, 2016 14:00 — forked from iwasrobbed/gist:5528897
UICollectionView w/ NSFetchedResultsController & NSBlockOperation. Idea originated from Blake Watters (https://github.com/AshFurrow/UICollectionView-NSFetchedResultsController/issues/13)
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
self.blockOperation = [[NSBlockOperation alloc] init];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
__weak UICollectionView *collectionView = self.collectionView;
// I just implemented that with Swift. So I would like to share my implementation.
// First initialise an array of NSBlockOperations:
var blockOperations: [NSBlockOperation] = []
// In the did change object method:
func controller(controller: NSFetchedResultsController, didChangeObject anObject: AnyObject, atIndexPath indexPath: NSIndexPath?, forChangeType type: NSFetchedResultsChangeType, newIndexPath: NSIndexPath?) {
if type == NSFetchedResultsChangeType.Insert {
println("Insert Object: \(newIndexPath)")