NSPredicate cause update editing to return NSFetchedResultsChangeDelete not NSFetchedResultsChangeUp

Posted by Matthew Weiss on Stack Overflow See other posts from Stack Overflow or by Matthew Weiss
Published on 2010-04-15T14:44:24Z Indexed on 2010/05/09 6:28 UTC
Read the original article Hit count: 270

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about core-data

Related posts about predicate