【问题标题】:iCloud Drive documents not included in NSMetadataQuery resultsNSMetadataQuery 结果中未包含 iCloud Drive 文档
【发布时间】:2015-02-23 11:20:12
【问题描述】:

我有一个基本的 iOS 8 应用程序,它在应用程序的 iCloud 容器和 iCloud Drive 中列出了用户的文档。

我的问题是,直接在 iCloud Drive(Finder → Go → iCloud Drive)中的文档不包含在元数据查询的结果中。该查询仅在应用的 iCloud 容器的 Documents 文件夹中返回结果。

我这样初始化查询:

self.query = [NSMetadataQuery new];
self.query.searchScopes = @[NSMetadataQueryUbiquitousDataScope,
   NSMetadataQueryUbiquitousDocumentsScope,
   NSMetadataQueryAccessibleUbiquitousExternalDocumentsScope]; // iCloud Drive

权利如下所示:

<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
    <string>$(TeamIdentifierPrefix)com.my.app</string>
    <string>iCloud.com.my.app</string>
</array>

更奇怪的是:iCloud Drive 中的一些文档有时会出现,但如果我将它们从 iCloud Drive 中移出并重新移入,它们就不再显示了。

【问题讨论】:

    标签: ios icloud nsmetadataquery icloud-drive


    【解决方案1】:

    想通了。 iCloud Drive 文档不在应用的容器中,因此不包含在元数据查询结果中,因为应用无法访问外部文件。

    使用文档选择器打开文档后,应用程序就可以访问该文档,并且从那时起它将成为元数据查询结果的一部分(直到用户将其移出 iCloud Drive)。

    我观察到的另一件事是:如果用户在 Mac 上将文档从 iCloud Drive 中移出,则元数据查询将不会在 iOS 上收到更新。尝试在 iOS 上打开文档只会导致错误(找不到文件)。

    【讨论】:

      【解决方案2】:

      我也想直接在iCloud驱动器中获取文件和目录。我发现一个名为“文档5”的APP已经完成了这个。这是我的问题:iCloud Drive list directories and files through NSMetadataQuery。

      【讨论】:

      • 我知道您没有足够的代表来发表评论,但答案不是提问的媒介。
      猜你喜欢
      • 2016-02-16
      • 2019-12-14
      • 2018-04-21
      • 2014-02-09
      • 2014-10-10
      • 2011-12-18
      • 2014-11-22
      • 1970-01-01
      • 2015-11-17
      相关资源
      最近更新 更多