Reputation: 259
I am having a bit of an issue which is .... well a bit frustrating. But that is due to my own (lack of) skill as a programmer :).
Basically, I have an online rails service that sends blog posts to my app (made with rest kit and core data). Restkit then maps them onto a tableview. Once restkit does that, I make a timestamp in my app when the 'last successful' request was made to the server. Works perfectly.
Next time I update, it sends that timestamp to the rails app which only then sends back objects (in JSON) which were added since then (i.e. a delta update).
Now for the issue, for some reason, when restkit receives this, it then deletes all the objects from the previous updates in core data and only shows the 'delta'/new objects it receives in the JSON. So I think restkit thinks that since the old objects are not part of the new JSON then they must be orphaned and goes onto delete them.
How can I stop this from happening? My issue is I don't want to transmit my entire online database every time there is an update request (bandwidth waste and kinda inelegant I think). Is there no way to keep the coredata db intact and only 'add' to it?
I have seen some posts that ask the same question but none of them have an answer to this (I think, but I can be stupid at times)!
Please help
Regards
Upvotes: 2
Views: 1034
Reputation: 259
Figured it out;
Look into RkManagedObjectLoader.m file and look for a method deleteCachedObjectsMissingFromResult
Disable this method to prevent anything in core data being deleted.
Hope this helps
Upvotes: 1