NSFetchedResultsController delegate exception

I have an application that uses a table view to display a list of items from my master data. I use a remote api and I update my content after pulling out the table view - this calls the API call.

Data is retrieved, analyzed and inserted / updated into my master data.

I sometimes get an error after saving my underlying data context ... Please note that I do not use multiple threads for this and, as I said, it seems that this does not always happen.

I'm literally losing my mind. This guy seems to have a similar problem, but I still can’t fix my solution: The CoreData error is driving me crazy ... CoreData: a serious application error. Exception thrown by delegate NSFetchedResultsController

Here is the complete error:

2012-07-31 14:14:47.332 MyApp[2893:11303] 
*** Assertion failure in -[_UITableViewUpdateSupport _setupAnimationsForNewlyInsertedCells], 
/SourceCache/UIKit_Sim/UIKit-1914.84/UITableViewSupport.m:1133
2012-07-31 14:14:47.332 MyApp[2893:11303] CoreData: error: Serious application error.  
An exception was caught from the delegate of NSFetchedResultsController during a call to -
controllerDidChangeContent:.  
Attempt to create two animations for cell with userInfo (null)

UPDATE

I have a predicate for my select query. To seem like objects previously loaded from the API that are missing from the new JSON result are being deleted. I set the hideFromUser flag, this is saved in my master data.

YES, . , . , - . , , , ... , , , , " " " "?

, .

:

1) " " (NSPredicate , ).

2) NSArray JSON.

3) , createABookOfClass: withJSON: ( json), , . : " ".

4) , , .

[[DPLocalStore getInstance] hideFlagItemsOfType:NSStringFromClass([MyFavouriteBook class])];

NSArray * itemsJSON = [data mutableObjectFromJSONData];

[itemsJSON enumerateObjectsUsingBlock:^(NSDictionary *obj, NSUInteger idx, BOOL *stop) {     
    [[DPLocalStore getInstance] createABookOfClass:[MyFavouriteBook class]
                                          withJSON:obj];
}];

NSError *error = nil;
BOOL didsave = [[DPLocalStore getInstance] save:&error];

, , , Object A, , : hide . , , NSFetchedResultsController ... ... ...

+5
1

, , , , , , , .

controller:didChangeObject:atIndexPath:forChangeType:newIndexPath: switch NSFetchedResultsChangeMove:

case NSFetchedResultsChangeMove:
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                     withRowAnimation:UITableViewRowAnimationFade];

    // Reloading the section inserts a new row and ensures that titles are updated appropriately.
    [tableView reloadSections:[NSIndexSet indexSetWithIndex:newIndexPath.section]
             withRowAnimation:UITableViewRowAnimationFade];
    break;

( ), , controller:didChangeObject:atIndexPath:forChangeType:newIndexPath: , , , - .

, Apple. , NSFetchedResultsChangeMove . , - !

:

case NSFetchedResultsChangeMove:
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                     withRowAnimation:UITableViewRowAnimationFade];
    [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath]
                     withRowAnimation:UITableViewRowAnimationFade];
    break;

, . -, , " ".

.

+9

All Articles