Cloud sync between iPad / iPhone

I have a Core Data application that will eventually become a universal iPhone / iPad application.

I would like to implement cloud synchronization so that the iPhone and iPad running in the application can exchange data. I plan to use the recently released Dropbox API . Anyone have any thoughts on how best to do this? The Dropbox API allows applications to store files in the cloud. What I was thinking about was the original storage of the database (sqlite) for the application in the cloud, and then downloading this database, but then I realized that using this method would make it difficult to merge the changes (instead of replacing the entire database).

Any thoughts are appreciated. Thanks.

+7
synchronization iphone cloud dropbox ipad
source share
4 answers

If you succeed, the easiest way to sync (today) is to have three copies of your data locally: the copy you downloaded last (the “old”), the copy made by the local changes (“mine”), and the copy is now loaded with server ("their").

Then sort all the entries in all three files and go one by one:

  • if old == mine, use them
  • else if old == them use my
  • otherwise you have a conflict; something like that (for example, always use mine, aka "the last writer wins")

Please note that “mine” or “their” or “old” may not exist. The above rules still apply in this case; if the result you select does not exist, you will want to delete the entry in the output file.

Finally, upload the resulting file back to the server so that it becomes “your” base for the next guy. Then copy the new file to the local "old" and "my" databases.

(There are more space-efficient algorithms than mentioned above ... but there are no simpler ones :) And disk space these days is pretty cheap, especially if you compress files.)

+5
source share

You might want to use a different synchronization method. What type of data will you be dealing with?

I have had great success using lightweight rail.

+1
source share

You can watch GameKit for data exchange. Otherwise, it seems to you that you just need to control the synchronization with the intermediate file server.

0
source share

You probably want to export the data in some format other than the sqlite native format. If I was developing something like this, I think JSON would probably be my choice.

I did not watch the Dropbox API, but they support uploading and uploading file differences, not the whole file, right? Depending on how the API works, perhaps your application understands their “diff” format and working with it might be easier ...

0
source share

All Articles