NSPredicate cause update editing to return NSFetchedResultsChangeDelete not NSFetchedResultsChangeUp
- by Matthew Weiss
I have predicate inside of - (NSFetchedResultsController *)fetchedResultsController in a standard way starting from the CoreDataBook example.
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"state=%@ && date = %@ && date < %@", @"1",fromDate,toDate];
[fetchRequest setPredicate:predicate];
This works fine however when editing an item, it returns with NSFetchedResultsChangeDelete not Update. When the main view returns, it is missing the item. If I restart the simulator the delete was not saved and the correct editing result is shown the the predicate working correctly.
case NSFetchedResultsChangeDelete:
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
I can confirm the behavior by commenting out the two predicate lines ONLY and then all works as it should correctly returning with the full set after editing and calling NSFetchedResultsChangeUpdate instead of NSFetchedResultsChangeDelete.
I have read http://matteocaldari.it/2009/11/multiple-contexts-controllers-delegates-and-coredata-bug
who reports similar behavior but I have not found a work around to my problem.
I can