【问题标题】:iOS accessing root of iCloud Drive with FileManageriOS 使用 FileManager 访问 iCloud Drive 的根目录
【发布时间】:2018-09-02 10:45:48
【问题描述】:

我基本上是在做这方面的变化:

let dir = fileManager.url(forUbiquityContainerIdentifier: nil)?
let files = try fileManager.contentsOfDirectory(at: dir)

试图进入 iCloud Drive 的根目录(即“/”),我有一些不在任何文件夹中的文件。

但是,dir 是(我猜应该是)我应用的文件夹。

是否可以访问 iCloud Drive 的根目录?我的意思是,用户显然可以将文件放在这里,但我可以进入那个目录吗? (请注意,目前我试图避免使用DocumentPickerViewController。)

【问题讨论】:

    标签: ios icloud-drive


    【解决方案1】:

    无法直接访问应用的 iCloud 容器之外的文件。如果您想让用户允许您的应用访问可能存储在其他地方的文件,您需要UIDocumentPickerViewController

    有关 iCloud 文档的更多信息可在此处找到: https://developer.apple.com/library/content/documentation/General/Conceptual/iCloudDesignGuide/Chapters/DesigningForDocumentsIniCloud.html#//apple_ref/doc/uid/TP40012094-CH2-SW1

    【讨论】:

    • 啊。认为是这种情况,但希望您仍然可以访问非应用程序特定的根目录,例如 Dropbox 或 Google Drive 或其他云存储。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-03-08
    • 2019-12-16
    • 2016-01-07
    • 2016-12-22
    • 2017-03-14
    • 2023-03-11
    • 1970-01-01
    • 2016-02-26
    相关资源
    最近更新 更多