I have an app that has a bunch of Core Data that it needs to sync. I am going to use Dropbox to sync a bunch of devices together, at least unless I can find a better solution. There are 4 main things that need to be synced: doctors, residents, and two different types of points (which are placed by the user on a graph). I don’t have any IDs attatched to these entities because I thought it would make it too difficult to sync. I was thinking of syncing them like this:
- I make a plist with three sub-dictionaries called “add” and “delete”. Both (“add” and “delete”) have an array for each entity that I need synced (doctor, resident, points, etc).
- Each time the user adds or deletes one of these things, I add a new dictionary to the appropriate array containing all the attributes and values of the attributes for that object that was added/deleted.
- Edits (you can only edit points, not residents or doctors) to something will be recorded by adding the new, edited object, and deleting the old object. So the new object gets added to the appropriate “add” list and the old object gets added to the appropriate “delete” list
- In Dropbox, each device that we are trying to sync has a folder. When it syncs, it uploads the plist file to it’s own device folder. It also does a backup of it’s own sql file by uploading it to a backup folder named with the date and time.
- It then checks all of the other device’s folders and applies the changes in the plists found in those folders.
- Once it is done applying all of the changes to it’s own local database and saving them, it uploads it’s sql file to a “newest” folder in dropbox.
- If a device wants to reset it’s database, or a new device joins, it just downloads the sql file from the newest folder.
Any thoughts/ideas/suggestions?
Thanks
I ended up using this model more or less but instead of a device checking all the other devices changesets, it checks a changeset in its own device folder that all the other device write to as they make changes. This way it is a lot easier to organize the changes chronologically. This model has worked well for anyone who is wondering.
*note that i am answering my own question so that people know what i ended up doing and that it worked. sorry this wasnt really a question with a straight answer.