shawnwall
shawnwall

Reputation: 4607

Can I prevent RestKit+CoreData from overriding local entity changes?

I've configured a RKObjectMappingProvider subclass with a series of object mappings that map a variety of service endpoints to my local Core Data entities & persistent store. Let's say I have a service endpoint /api/workorders and I use loadObjectsAtResourcePath:usingBlock: to fetch a list of X workorders and persist to Core Data. Next, the user modifies 2 of those entities using the app but doesn't push the changes back to the service.

If the user again calls /api/workorders to fetch the latest workorders, is there a way to not have RestKit automatically override the local modifications to the changed entities?

Upvotes: 2

Views: 843

Answers (1)

Will Johnston
Will Johnston

Reputation: 864

The short answer is no, you have to do it yourself and it gets nasty quickly.

You would need to override the setter of a custom managed object class.

This kind of thing.

You would need a property to know it has been updated. You will need to create it and set it when the entity gets updated. I would do this at the row level, and then check the property and only update if the flag is not set. Of course you then need to handle the case if the user wants to update the value again :) Restkit is wonderful, but does not handle full syncing for you.

Upvotes: 1

Related Questions