Synchronize kernel data with a web server

I am creating a bird app. This app should also work offline. So I decided to use Core Data. I plan to have 1 table with approximately 700 records. All birds will be displayed in tabular form. The workflow should look like this:

  • The user launches the application
  • The request is sent to the server in the background
  • The answer is parsed.
  • Database updated

I am interested in the best way to do this. I want to add a query to the "last change" field, this will reduce the number of database updates. Should I delete all instances of my entity or loop them one by one, comparing the "last modified" field, and then update / delete / insert? Has anyone done profiling in time? When the user opens the bird screen at a time when old instances are already deleted and new ones are not inserted, he will see an empty table view, how to deal with this situation, do I need a tmp object? Are there any other flaws that I missed?

+3
ios web-services xcode core-data
source share
2 answers

If I understand correctly, you can change your bird both in the application and in the server database, and you want to save the last change and transfer it to the other side. Then you can use something like Last sync in your NSUserDefaults, and while sending a request to the server, you send it all the changes that you changed after your last synchronization (this is a simple request to the main data) and the server should also return you a list of birds which he updated after your last sync.so, you can also update them in your application. If you update the LastSync value.

If you always want to get all updated birds from the server, just use the second part of my answer.

+1
source share

All Articles