Syncing a local sqlite file to iCloud

我的未来我决定 提交于 2019-12-02 22:35:33

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.

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!