Vya*_*iuk 5 objective-c icloud-api macos-monterey
我的应用程序使用 iCloud 键值存储 Objective-C api,如下所示:
NSUbiquitousKeyValueStore* iCloudStorage = [NSUbiquitousKeyValueStore defaultStore];
[iCloudStorage synchronize];
[iCloudStorage setString:@"Test" forKey:@"TestStringKey"];
[iCloudStorage synchronize];
NSString* value = [iCloudStorage stringForKey:@"TestStringKey"];
Run Code Online (Sandbox Code Playgroud)
要使用此 api,我将以下权利添加到权利文件中:
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
Run Code Online (Sandbox Code Playgroud)
此外,我还在developer.apple.com 上的证书、ID 和配置文件中为我的应用程序标识符启用了 iCloud 支持,因此它看起来如 iCloud 键值存储文档中所述。问题是这段代码在 Monterey 之前的所有 MacOS 版本上都可以正常工作,但是该代码在 Monterey 版本上不起作用 - 无法保存字符串或从存储中检索它,并且在日志中我看到以下消息:
2022-03-15 17:41:17.119843+0300 [Connection] Unable to find entitlement for KVS store
2022-03-15 17:41:17.119888+0300 [Connection] Trying to initialize NSUbiquitousKeyValueStore without a store identifier. Please specify a store identifier in your entitlements or initializer.
Run Code Online (Sandbox Code Playgroud)
在重新阅读此 api 的文档并确保我已按照此处所述设置了所有内容后,我没有找到问题的解决方案,因此我寻求帮助。
| 归档时间: |
|
| 查看次数: |
329 次 |
| 最近记录: |