I need help understanding how to manage the API for an iPhone application that persists remote objects using CoreData. From my understanding, when the iOS app fetches the remote objects, it loads all the objects at the resource path.
For subsequent requests, I want to reduce overhead by having the web server return only objects that have been updated since the last update time. I perform this by returning objects where updated_at is newer than the last_update time of the request.
RestKit then parses and maps the modified objects to CoreData. Is this implementation the proper way of performing synchronization using RestKit and CoreData or am I missing a layer somewhere in between?
Thanks!
Typically RESTful interfaces should try and head “back to the basics”. In your case I recommend using the HTTP Header
If-Modified-Since. It is slightly cleaner than passing another parameter because RestKit will handle the HTTP status responses without you doing anything.Otherwise, your method seems normal. Server synchronization is an enormous problem and there is a lot of literature and methods dealing with it. If you want to do something more complex then a quick web search will turn up a handful of methods, but your approach is what I usually end up doing.
If a user can edit data on your app, then there is the problem of synchronizing modifications made on the device. For this you typically set a object scope “modified” flag and only upload an object if it is modified.