Reputation: 607
I'm creating an app about birds. This app should also work in offline mode. So I decided to use Core Data. I plan to have 1 table with approximately 700 records. All the birds will be displayed in a table view. Workflow should be like this:
I'm interested what's the best way to do this. My point is to add to the request "last modified" field, this will decrease the number of times database should be updated. Should I delete all instances of my entity, or loop them one by one comparing "last modified" field and then update/delete/insert ? Has anybody made time-profiling ? When user opens screen with birds in the period when old instances are already deleted and new are not inserted, he will see an empty table view, how to handle such situation, do I need a tmp entity ? Are there any other pitfalls I've missed ?
Upvotes: 4
Views: 3481
Reputation: 2600
Following might be helpful
http://publications.csail.mit.edu/tmp/MIT-CSAIL-TR-2005-014.pdf
http://iphone2009.crowdvine.com/talk/presentation_file/5104/Grover_Syncing.pdf
https://stackoverflow.com/a/5052208/1294448
Upvotes: 1
Reputation: 5966
If i understood you right, you can modify your bird both in app and in a server database, and you want the last change to be saved and transferd to the other side. Then you can use something like Last sync
in your NSUserDefaults, and evey time you send a request to the server,you send him all the enteties you modified after your last sync(that'a an easy request to a core data),and the server should also give you back a list of birds he updated after your last sync.so you could update them in your app too.athen you update your LastSync value.
If you just always to get all the updated birds from server,just use the second part of my answer.
Upvotes: 1