11

I'm getting this error in my app:

*** Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit/UIKit-2372/UICollectionView.m:2801

It happens in my -controllerDidChangeContent: method on this line:

[self.collectionView performBatchUpdates:^{...}];

Does anyone know what causes this? My code is closely based off of https://gist.github.com/4440c1cba83318e276bb and I'm at a loss.

Thanks!

tkanzakic
  • 5,499
  • 16
  • 34
  • 41

3 Answers3

9

These types of assertions get thrown as exceptions. Wrap the batch updates in a try/catch and dump the exception description. It will tell you exactly what it doesn't like about your call.

In other words:

    @try
    {
        [self.collectionView performBatchUpdates:^{...}];
    }
    @catch (NSException *except)
    {
        NSLog(@"DEBUG: failure to batch update.  %@", except.description);
    }
FranG
  • 91
  • 1
  • 2
1

I bet it's because of that your

-controllerDidChangeContent

is being called in background thread multiple times, and performBatchUpdates is still working when another thread calls it, so it leads to incorrect behavior.

Solution - try to wrap it in @synchronized or using NSLocks

  • It was definitely being called on the main thread so this wasn't the issue –  Dec 08 '12 at 00:32
1

The issue was not setting the FRC delegate to nil on view didDisappear.