"Virtual" deletion and NSFetchedResultsController
"Virtual" deletion and NSFetchedResultsController
- Subject: "Virtual" deletion and NSFetchedResultsController
- From: Rick Mann <email@hidden>
- Date: Fri, 23 Nov 2012 18:40:23 -0800
One of the features in my app is a set of alerts that come in as messages. They're displayed with a typical message UI, like in the Mail app. There's a table listing the subject and body prefix for each alert in a cell.
I use an NSFetchedResultsController to coordinate with the model. The problem is, Alerts are not actually deleted. Instead, they have a "deleted" property set to true, and a predicate in the fetch requests tests this.
Unfortunately, setting the deleted flag to true doesn't cause the FRC to behave the way I had hoped. I had hoped that it would treat the object as having been "deleted from the result set", because it no longer satisfies the predicate. Instead, I get an "updated" notification for the object, and the predicate's result set still contains the object.
I think the only way around this is to re-perform the fetch after updating the deleted flag on the object, and manually handle the table row delete (in the updated delegate callback).
Unfortunately, this also means I really can't use a nested context for my detail view (which has previous/next buttons), because it won't get properly updated, either. Well, I guess it can, but it has to be handled similarly.
All in all, it seems much more unwieldy than if FRC's notifications were with respect to the result set, not the managed object context.
Any other suggestions?
Thanks,
--
Rick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden