Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sync core data with web server

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:

  1. User starts app
  2. Request is sent to server in background
  3. Response is parsed
  4. Database is updated

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 ?

like image 862
user801255 Avatar asked May 17 '26 01:05

user801255


2 Answers

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

like image 148
Bishal Ghimire Avatar answered May 19 '26 15:05

Bishal Ghimire


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.

like image 24
Nikita Pestrov Avatar answered May 19 '26 16:05

Nikita Pestrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!