Reputation: 3
I was wondering if you have ever used AFIncrementalStore to sync between Core Data and a REST API? And if you so, it is a good approach to use it without the Heroku Core Data Buildpack? I don't like dark magic :P
My Core Data model might not match exactly the REST API.
Upvotes: 0
Views: 564
Reputation: 4761
AFIncrementalStore works fine with a simple REST API.
You may have to override the representationForResponse
method for a fine match with your models but it should be all that is needed (except from the init part of course)
My advice: make an exact match between the API and your CoreData models and then use categories to generate the data the way you want them.
I'm currently doing an e-commerce app and my API send me products with an expiration_date
which is a unix timestamp. I save as it is in CoreData and then I have a category on my NSManagedObject Product
methods like hoursRemaining
, weeksFromNow
and so on for an easier display in the UI.
For the relationships, I'm not use those for automatic fetching with AFIncrementalStore so I can't say much.
Upvotes: 2