Syncing a local sqlite file to iCloud

后端 未结 3 1207
北海茫月
北海茫月 2021-02-04 02:53

I store some data in my iOS app directly in a local .sqlite file.  I chose to do this instead of CoreData because the data will need to be compatible with non-Apple platforms.

相关标签:
3条回答
  • 2021-02-04 03:44

    Try those two solutions from Ray Wenderlich:

    Exporting/Importing data through mail: http://www.raywenderlich.com/1980/how-to-import-and-export-app-data-via-email-in-your-ios-app

    File Sharing with iTunes: http://www.raywenderlich.com/1948/how-integrate-itunes-file-sharing-with-your-ios-app

    I found it quite complex but helped me a lot.

    0 讨论(0)
  • 2021-02-04 03:45

    I've considered the possibility of transferring a database file through iCloud but I think that I would run into classic problems of timing - slow start for the user - and corrupted databases if the app is run on multiple devices simultaneously. (iPad/iPhone for example).

    Sooo. I've had to use the transaction logs method. It really is difficult to implement, but once in place, seems ok.

    I am using Apple's SharedCoreData sample as the base for this work. This link requires an Apple Developer Account.

    I did find a much much better solution from Tim Roadley however this only works for IOS and I needed both IOS and MacOS.

    rant> iCloud development really has to get easier and more stable! /rant

    0 讨论(0)
  • 2021-02-04 03:58

    Both method 1 and method 2 seem doable. Perhaps a combination of the two in fact - use iCloud to send a separate database file that is a subset of data - i.e. just changed items. Or maybe another file format instead of sqlite db - XML/JSON/CSV etc.

    Another alternative is to do it outside of iCloud - i.e. a simple custom web service for syncing. So each change gets submitted to a central server via JSON/XML over HTTP, and then other devices pull updates from that.

    Obviously it depends how much data and how many devices you want to sync across, and whether you have access to an appropriate server and/or budget to cover running such a server. iCloud will do that for "free" but all it really does is transfer files. A custom solution allows you to define your syncing model as you wish, but you have to develop and manage it and pay for it.

    0 讨论(0)
提交回复
热议问题