I am trying to sync an iphone app with a web server using two flags - synched and is_deleted as described here https://stackoverflow.com/a/5052208
When the user deletes an item in the app, I set the is_deleted flag to true. Now I want to make sure that object does not show up in my app again since it has been deleted (for example in a table view), but I need to keep the object to perform the sync. So here is the question:
What is the best way to exclude all objects with is_deleted flag from showing up in the app by default?
I can think of two options now:
Make almost every single query in the app check if the item is_deleted - does not seem very efficient at all
Find a more generic way to automatically exclude all is_deleted=YES objects from the app, for example by overriding awakeFromFetch or some other method. But I am not sure how to exclude the objects from the context but keep them in the database for my sync.
What is the best way to do this? Is #2 even possible?
I guess you are considering this for the case when the user wants to delete some objects but there is no internet connection, right?
In this case I would suggest actually deleting those objects from the database and storing the info about those deleted objects in a different form. For instance you could have a separate entity named “XXDelayedOperation” which would have all the necessary info you need to create a NSURLRequest
. This looks like a more efficient way of handling it.