2014-10-31 46 views
0

从Xcode 5到Xcode 6的更改以及在线更改到iCloud管理系统时,我失去了将数据存储到iCloud中的键值存储的能力。更具体地讲,现在,既:iCloud上的默认容器不能用于键值存储

[[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; 

[NSFileManager defaultManager].ubiquityIdentityToken 

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

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

回答

1

我发现了一个修复。我首先尝试了Xcode 6的示例项目,目标是iOS6(我需要保持iOS6的兼容性)。我有能力在这些设置:

enter image description here

这似乎是默认容器设置不只有键值存储工作。也就是说,使用上面的设置,ubiquityIdentityToken返回nil。

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

我又试图检查iCloud的文件箱;)(黑客我的方式向伟大?):

enter image description here

这将导致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>