Reputation: 1281
I need to update a task before it is deleted. I found when this line [self.fetchedResultsController objectAtIndexPath:indexPath];
is executed in NSFetchedResultsChangeDelete the app crashes.
case NSFetchedResultsChangeDelete:{
Task *task = [self.fetchedResultsController objectAtIndexPath:indexPath];
[self deleleReminderForTask:task];
[self checkForUpdateForTaskForDelete:task];
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
crash log:
CoreData: error: Serious application error. Exception was caught during Core Data change processing. This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification. *** -[_PFBatchFaultingArray objectAtIndex:]: index (40324416) beyond bounds (1) with userInfo (null)
Can anybody help me to fix this.
Upvotes: 0
Views: 143
Reputation: 119031
The fetched results controller has already been updated so you can't try to get the item from it. Instead you should use the object that is passed as a parameter to the delegate method. You should also check what you're doing with the deleted item is you still have issues.
Upvotes: 1