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