【问题标题】:Default container on iCloud not working for key-value storageiCloud 上的默认容器不适用于键值存储
【发布时间】:2014-12-27 06:32:31
【问题描述】:

在从 Xcode 5 到 Xcode 6 的更改以及对 iCloud 管理系统的在线更改中,我失去了将数据存储到 iCloud 中键值存储的能力。更具体地说,现在,两者:

[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];

[NSFileManager defaultManager].ubiquityIdentityToken

现在两者都返回 nil。以前(至少)URLForUbiquityContainerIdentifier 返回非零。

我尝试了这里给出的答案:Why ubiquityIdentityToken returns nil? 和这里 https://devforums.apple.com/thread/229509 但没有快乐。

【问题讨论】:

    标签: xcode6 icloud nsfilemanager key-value-store


    【解决方案1】:

    我已找到解决此问题的方法。我首先尝试了一个使用 Xcode 6 的示例项目,针对 iOS6(我需要保持 iOS6 兼容性)。我在功能下有这些设置:

    似乎默认容器设置不适用于键值存储。也就是说,通过上述设置,ubiquityIdentityToken 返回 nil。

    接下来我尝试检查 CloudKit 框,然后指定一个自定义容器。除了我的 iOS6 兼容性问题之外,这可能有效。 CloudKit 不适用于 iOS6。

    然后我尝试检查 iCloud 文档框(破解我的伟大之路?;)):

    这会导致 ubiquityIdentityToken 返回非零!当我在实际应用程序中进行此更改时,与此测试应用程序相反,我的键值存储再次工作! (它也适用于 iOS8.1)。

    我的授权文件的相关部分现在是:

    <key>com.apple.developer.icloud-container-identifiers</key>
    <array>
        <string>iCloud.$(CFBundleIdentifier)</string>
    </array>
    <key>com.apple.developer.icloud-services</key>
    <array>
        <string>CloudDocuments</string>
    </array>
    <key>com.apple.developer.ubiquity-container-identifiers</key>
    <array>
        <string>iCloud.$(CFBundleIdentifier)</string>
    </array>
    <key>com.apple.developer.ubiquity-kvstore-identifier</key>
    <string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
    

    【讨论】:

      猜你喜欢
      • 2016-10-19
      • 2013-02-07
      • 1970-01-01
      • 2013-08-08
      • 2013-04-04
      • 2013-12-11
      • 1970-01-01
      • 2017-11-21
      • 2013-06-08
      相关资源
      最近更新 更多