Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Synchronization with RestKit

I'm about to write a simple iPhone app that uses Core Data to store local copy of remote data that is fetched via RESTful web service. The data changes (new records being added) quite often. I came across RestKit and I'm wondering if it can do what I need. And what I need is to load all records in the beginning and then periodically download ONLY records that were added since previous check. Obviously there is no mystery about how that can be accomplished even by simply using NSURLConnection, but I hoped RestKit (probably in combination with a proper web service) would do that without me having to write all the synchronization logic. Again the key for me is that only new/changed data is fetched from the server.

like image 770
Joe Shmo Avatar asked Dec 10 '11 20:12

Joe Shmo


2 Answers

I agree - RestKit can do this, we've recently used it to do something similar in a recent project. We used a last-modified-date request header to indicate the last successful 'sync' time, which the server can use to return only the records modified since that date. A http 304 'not modified' status code was used to indicate no change when appropriate.

RestKit also includes a seeding facility, so you know up front the initial data set - you can seed it as the initial database easily, and fetch the updates, even upon first use of the application.

Some information I found useful regarding RestKit & CoreData mapping - https://github.com/RestKit/RestKit/blob/master/Docs/Object%20Mapping.md, and the Google group is a good source as well - https://groups.google.com/group/restkit. Hope this all helps.

like image 191
crafterm Avatar answered Nov 13 '22 12:11

crafterm


First of all: YES

RestKit handles CoreData very well. All you need to do is to provide mapping of your entities and it does the work for you.

For the second thing about selective sync, I really recommend checking StorageRoomApp it is a great, and not so expensive service that does exactly what you need.

They have a very good API that extends RestKit, it is very easy to use and their support is great. Take a look.

like image 4
shannoga Avatar answered Nov 13 '22 12:11

shannoga