如何使用iCloud存储和同步应用程序文件 [英] How to use iCloud to store and sync app files

查看:886
本文介绍了如何使用iCloud存储和同步应用程序文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一个iPhone应用程序,该应用程序将数据存储在本地文档文件夹中的文件中.现在我了解了iCloud技术,我的第一个问题是:当我有时需要检查新版本时,是否可以将iCloud用作目录?

I already have an iPhone App that stores data in a file in the local documents folder. Now I learnt about iCloud technologies and my first question was: is there a way to use iCloud as a directory when sometimes I check for new versions?

我的意思是:我可以避免使用UIDocument,文件协调器和文件演示者吗?我只想知道是否可以将iCloud视为一个特殊文件夹,而仅使用NSFileManager来推送和检索文件.

I mean: can I avoid using UIDocument, file coordinators and file presenters? I want just to know if could treat iCloud like a special folder and only use NSFileManager to push and retrieve files.

最后一点:我不使用Core Data或任何数据库,我只有一个数据文件.

Last note: I don't use Core Data or any database, I only have a data file.

我已经阅读了Apple iCloud官方文档,所以不要将我链接到他们.我只需要一些代码示例.

I already read the official Apple iCloud documentation so don't link me to them. I only need some code examples.

推荐答案

我知道您的感觉,iCloud有点令人生畏.但是,我认为无法绕过UIDocument,文件协调器等,而只能将iCloud用作简单文件夹.

I know how you feel, iCloud is a bit daunting. However, I think there is no way around UIDocument, file coordinators etc. and to simply use iCloud as a simple folder.

如果您正在寻找一个易于理解的示例代码,请看一下这篇文章:

If you are looking for an easy to understand sample code, please have a look at this post:

iCloud基础知识和代码示例

我提供了完整的示例代码,其中涵盖了iCloud的最低要求,并且几乎像目录一样使用它.也许这使您减少使用UIDocument,文件协调器等的麻烦.

I included a full sample code which covers the bare minimums of iCloud and pretty much uses it like a directory. Perhaps this makes it less daunting for you to use UIDocument, file coordinators etc.

但是,我希望像您一样,可以采用一种更好的兼容旧纪录片文件​​夹的方式,并且更加兼容.但是,由于这是iCloud,并且由于iCloud还有其他功能(例如使所有内容在不同设备上保持同步,不断更新到云等),因此无法绕开UIDocument等.

But, like you, I wish there was an easier and more compatible way with the good old documentary folder idea. However, as this is iCloud and as iCloud does several things more (like keeping everything in sync on different devices, constantly updating to cloud etc.), there will be no way around UIDocument etc.

这篇关于如何使用iCloud存储和同步应用程序文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆