简体   繁体   English

如何为核心数据数据库启用iCloud同步?

[英]How can I enable iCloud synchronization for my Core Data database?

I want to make my app sync its SQLite Core Data store between devices using iCloud. 我想让我的应用使用iCloud在设备之间同步其SQLite Core Data存储。 Right now I let users manually sync their SQLite files using Dropbox, but that is cumbersome for users. 现在,我让用户使用Dropbox手动同步他们的SQLite文件,但这对用户来说很麻烦。 I want it to be automatic. 我希望它是自动的。

What is the best practice to achieve this functionality? 实现此功能的最佳实践是什么? Do I need any special provisioning profiles? 我是否需要任何特殊的配置文件?

I read somewhere that I need to set up my Core Data database to use UIManagedDocument but I haven't found anywhere that explains how to do this clearly. 我在某处读到需要设置我的Core Data数据库以使用UIManagedDocument的地方,但是我找不到任何地方可以清楚地说明如何执行此操作。 Any suggestions? 有什么建议么?

Turn on cloud syncing. 打开云同步。 That is step one. 那是第一步。 From there it depends on your application and its requirements. 从那里开始,它取决于您的应用程序及其要求。

Sorry for the short answer but your question is rather vague and you do not have any requirements for your app. 简短答案很抱歉,但是您的问题比较模糊,您对应用程序没有任何要求。

Assuming it is just a sqlite file all you need to do is turn on cloud syncing, change your Core Data stack to handle being async and Bob's your uncle. 假设这只是一个sqlite文件,您需要做的就是打开云同步,更改您的Core Data堆栈以处理异步,而Bob是您的叔叔。

Update 更新资料

It is unlikely you will need to use UIManagedDocument . 您不太可能需要使用UIManagedDocument I would say that unless you have a kitchen sync type application you are fine using the Core Data ubiqutous store syncing at the NSPersistentStore level. 我要说的是,除非您有一个厨房同步类型的应用程序,否则可以在NSPersistentStore级别使用Core Data无处不在的商店同步来进行NSPersistentStore

At this time, quite a few people are having issues with UIManagedDocument so I would avoid it unless you absolutely need to sync things that are not contained within the sqlite file. 目前,相当多的人在UIManagedDocument方面遇到问题,因此除非您绝对需要同步sqlite文件中未包含的内容,否则我将避免使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM