2015-02-23 81 views
2

假设我们有一个名为“myImage.png”的图像文件,并通过www.icloud.com网站将此文件添加到我的iCloud驱动器中。可以从iCloud驱动器下载文件吗?

为此,我测试许多代码像thisthis,最后尝试使用命令startDownloadingUbiquitousItemAtURL和他们没有工作(我只能是否存在下载这个路径里面的文件如下:)

/用户/ mynamemac /库/开发商/ CoreSimulator /设备/ 07BAC437-D32A-44BB-BC25-5683222B7516 /数据/资料库/移动%20Documents/

知道我想借文件存储在我的iCloud Drive和保存在我的目录中,我如何下载此文件并保存在我的设备上?

+0

是否可以通过iCloud使用任何iCloud apis共享链接? – iGo 2016-11-02 09:35:37

回答

2

一般来说,您应该首先打开iCloud驱动器,将其添加到您的info.plist文件中。

<key>NSUbiquitousContainers</key> 
<dict> 
    <key>iCloud.com.example.MyApp</key> 
    <dict> 
     <key>NSUbiquitousContainerIsDocumentScopePublic</key> 
     <true/> 
     <key>NSUbiquitousContainerSupportedFolderLevels</key> 
     <string>Any</string> 
     <key>NSUbiquitousContainerName</key> 
     <string>MyApp</string> 
    </dict> 
</dict> 

然后,你应该将项目的Capabilites选项卡下打开iCloudXCode会自动为您添加权利。
您可以使用此代码来检查您是否有权访问iCloud。
[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
有关更多信息,请参阅iCloud Design Guide

相关问题