This question is about using Dropbox to sync an sqlite Core Data store between multiple iOS devices. Consider this arrangement:
An app utilizes a Core Data store, call it
local.sql
, saved in the app's ownNSDocumentDirectory
The app uses the Dropbox Sync API to observe a certain file in the user's Dropbox, say,
user/myapp/synced.sql
The app observes
NSManagedObjectContextDidSaveNotification
, and on every save it copieslocal.sql
touser/myapp/synced.sql
, thereby replacing the latter.When the Dropbox API notifies us that
synced.sql
changed, we do the opposite of part 3 more or less: tear down the Core Data stack, replacelocal.sql
withsynced.sql
, and recreate the Core Data stack. The user sees "Syncing" or "Loading" in the UI in the meantime.
Questions:
A. Is this arrangement hugely inefficient, to the extent where it should be completely avoided? What if we can guarantee the database is not large in size?
B. Is this arrangement conducive to file corruption? More than syncing via deltas/changelogs? If so, will you please explain in detail why?