WOOPS - May have found the answer here...http://sensiblecocoa...ddata#entry9521 --- Mark
Hi All -
I'm still a newbie at this so I'm probably missing something pretty straight forward. I've got a filterPredicate set (working) that only presents items from Core Data with a delete flag that's equal to false (i.e. not deleted). And, I've got sectionActions.willDeleteItem getting called in edit mode when the delete button is pressed.
In the willDeleteItem code, I'm able to update the delete flag to true. That will keep the item in Core Data marked as deleted so that it can be sent to the backend later. However, when I return false from willDeleteItem to prevent the delete action completing, the table view display still shows the deleted item. As far as I can tell, the SCTableViewController is not refreshing the content and re-applying the filterPredica
Is there any way to use willDeleteItem to update the content of the item so a filterPredicate will exclude it (i.e. soft delete) without actually completing the deletion?
The alternative I'm looking at now is to use willDeleteItem to create a duplicate item that's marked for deletion and return true to allow the existing Core Data item to be deleted. However, that seems like a pretty expensive operation for something that's got to be regularly needed and I'm not sure at this point that it won't create other issues...
Here's my code:
NSPredicate *excludeDeletedObjects = [NSPredicate predicateWithFormat:@"deleteFlag == NO"];
SCArrayOfObjectsSection *objectsSection = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil
objectsSection.sectionActions.willDeleteItem = ^BOOL(SCArrayOfItemsSection *itemsSection, NSObject *item, NSIndexPath *indexPath)
// change deleteFlag to true to pass in next sync to server
[item setValue:[NSNumber numberWithBool:YES] forKey:@"deleteFlag"];
// return false to prevent deletion actual deletion
Edited by markr, 27 February 2014 - 11:03 AM.