简体   繁体   English

iCloud同步文件和核心数据

[英]iCloud sync files and core data

In my app I save images in file manager and their metadata(image name,created date,notes and image path) in core data. 在我的应用程序中,我将图像保存在文件管理器中,并将它们的元数据(图像名称,创建日期,注释和图像路径)保存在核心数据中。 I want to know the best practice to sync these data using iCloud. 我想知道使用iCloud同步这些数据的最佳实践。

If you save the images in the ubiquity container they will be synchronised across devices. 如果将图像保存在普遍存在的容器中,它们将在设备之间同步。 However you may need to store a relative pathname rather than an absolute pathname. 但是,您可能需要存储相对路径名而不是绝对路径名。

If you take a look at the the sample apps at the link below you will find the app uses iCloud to synchronise the Core Data database using transaction logs and it uses iCloud to synchronise the backup files the user makes. 如果您在下面的链接上查看示例应用程序,您会发现该应用程序使用iCloud通过事务日志同步Core Data数据库,并且使用iCloud同步用户创建的备份文件。 So while this is not exactly what you want it would be pretty easy to modify the code for saving the backup files to iCloud to save your files to iCloud. 因此,尽管这不是您想要的,但修改用于将备份文件保存到iCloud的代码以将文件保存到iCloud相当容易。

You do need to remember that iOS will not automatically download files from iCloud so you would have to do that from your App prior to trying to use them on the device. 您需要记住,iOS不会自动从iCloud下载文件,因此在尝试在设备上使用它们之前,您必须从您的App中下载文件。

http://ossh.com.au/design-and-technology/software-development/ http://ossh.com.au/design-and-technology/software-development/

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

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