IOS 5.1 Backup / Restore App file from Documents Directory to / from iCloud

时光毁灭记忆、已成空白 提交于 2019-12-11 18:24:01

问题


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...

Now I would like to do the same process but, set it up for iCloud. Looking for the following function:

  1. Tap a button to backup the *.sqlite file from the Apps Document Directory up to iCloud at users preference.
  2. Tap a button to copy the *.sqlite file down from iCloud to the Apps Document Directory.

I have been struggling trying to find the solution, any help will be greatly appreciated.


回答1:


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];

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];

and if you are getting it from iCloud to Apps Documents directory

[[[NSFileManager alloc]init] setUbiquitous:NO itemAtURL:your_iCloudURL destinationURL:localDirectoryURL error:&errorsss];


来源:https://stackoverflow.com/questions/12083327/ios-5-1-backup-restore-app-file-from-documents-directory-to-from-icloud

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