Skip to content

Instantly share code, notes, and snippets.

@acalism
Last active January 11, 2016 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acalism/bdb832addcc6e9426534 to your computer and use it in GitHub Desktop.
Save acalism/bdb832addcc6e9426534 to your computer and use it in GitHub Desktop.
Exception at -[UITableView _endCellAnimationsWithContext:]

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/UITableView.m:1222

if continue to run, get this message, CoreData: error: Serious application error. An exception was caught from the delegate of NSFetchedResultsController during a call to -controllerDidChangeContent:. attempt to delete and reload the same index path (<NSIndexPath: 0xc000000000018016> {length = 2, path = 0 - 3}) with userInfo (null)

Related code, as follows,

- (void)controllerWillChangeContent:(NSFetchedResultsController*)controller {
    [self.tableView beginUpdates];
}

- (void)controllerDidChangeContent:(NSFetchedResultsController*)controller {
    [self.tableView endUpdates];
}

- (void)controller:(NSFetchedResultsController*)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath*)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath*)newIndexPath
{
    if (type == NSFetchedResultsChangeInsert) {
        [self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (type == NSFetchedResultsChangeMove) {
        if ([indexPath isEqual:newIndexPath]) { // bug fixed for iOS 8 and 9
            [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
//            ESMessageCenterCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
//            [self configureCell:cell atIndexPath:indexPath];
        } else {
            [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
            [self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
        }
    } else if (type == NSFetchedResultsChangeDelete) {
        [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else {
        [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }
}
@acalism
Copy link
Author

acalism commented Nov 20, 2015

I don't know how to solve the problem, at this time.

@ppaulojr
Copy link

Nobody seems to really know how to solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment