IOS 5.1从文档目录备份/恢复应用程序文件到/从iCloud [英] IOS 5.1 Backup / Restore App file from Documents Directory to / from iCloud
问题描述
我已经为iPad创建了一个带有XCode 4.3.3的数据库(IOS 5.1)并进行了设置,以便用户可以备份数据库文件(* .sqlite)并将其恢复到DropBox。一切正常......
I have created a database (IOS 5.1) with XCode 4.3.3 for the iPad and have set it up so that the user can backup and restore the database file (*.sqlite) to DropBox. Everything works fine...
现在我想做同样的过程但是,为iCloud设置它。寻找以下功能:
Now I would like to do the same process but, set it up for iCloud. Looking for the following function:
- 点击一个按钮,将用户文档目录中的* .sqlite文件备份到用户首选项的iCloud。
- 点击按钮将* .sqlite文件从iCloud复制到Apps文档目录。
我一直在努力寻找解决方案,我们将非常感谢任何帮助。
I have been struggling trying to find the solution, any help will be greatly appreciated.
推荐答案
将文件移至从icloud你可以使用下面的代码。
For moving any file to and from icloud you can use this code below.
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:your iCloudURL destinationURL:localDirectoryURL error:&errorsss];
唯一的问题是,如果你要转向icloud,代码应为:
only thing is if you are moving to icloud the code should be :
[[[NSFileManager alloc]init] setUbiquitous:YES itemAtURL:localDirectoryURL destinationURL:your_iCloudURL error:&errorsss];
如果您从iCloud获取到Apps Documents目录
and if you are getting it from iCloud to Apps Documents directory
[[[NSFileManager alloc]init] setUbiquitous:NO itemAtURL:your_iCloudURL destinationURL:localDirectoryURL error:&errorsss];
这篇关于IOS 5.1从文档目录备份/恢复应用程序文件到/从iCloud的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!