【问题标题】:It is possible to download files from iCloud drive?可以从 iCloud 驱动器下载文件吗?
【发布时间】:2015-04-24 16:15:08
【问题描述】:

假设我们有一个名为“myImage.png”的图像文件,我通过网站 www.icloud.com 在我的 iCloud 驱动器上添加了这个文件。

为此,我测试了许多代码,例如thisthis,最后尝试使用命令startDownloadingUbiquitousItemAtURL,但它们都不起作用(我只能下载该路径中存在的文件下面:)

/Users/mynamemac/Library/Developer/CoreSimulator/Devices/07BAC437-D32A-44BB-BC25-5683222B7516/data/Library/Mobile%20Documents/

知道我想将文件存储在我的 iCloud Drive 中并保存在我的目录中,我该如何下载这个文件并保存在我的设备上?

【问题讨论】:

  • 是否可以使用任何 iCloud api 通过 iCloud 共享链接?

标签: ios objective-c ios8 icloud icloud-drive


【解决方案1】:

一般情况下,您应该先打开 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 了解更多信息。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2015-01-08
  • 2012-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-10-25
  • 2021-03-18
相关资源
最近更新 更多