Question

I'm using RestKit to manage syncing my CoreData objects with my server, and it's working great so far. I have a use case however, where I'm not sure what the best way is to proceed with RestKit.

RestKit presently deletes my orphaned managed objects that no longer exist on the server, and that's great, but sometimes, I don't want certain ones to be deleted.

For example, let's say I create a managed object, but I'm lacking internet access at the time. I save the managed object, but I can't save it on the server. I want this saved on the server later when I do have access to the server, but presently, that object will just get deleted on the next round as RestKit will see that these objects don't exist on the latest server response, and so will mark them for deletion.

I could put a "draft" flag on the objects, and flag them before ever getting a server update, and make sure to send all draft objects first to the server before doing the update. That seems like one possible solution.

However, I wondered if there's another way that RestKit supports.

Thanks! Palmer

Was it helpful?

Solution

Your solution is good. You don't need to ensure you send them first though if you add a predicate to filter them out in the fetch request block. Just be sure to reset the flag once they are uploaded.

That solution is cleaner than any alternative associated with identities in the fetch request block or ensuring that updates are sent out and confirmed before downloading updates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top