Dam*_*ien 5 macos cocoa objective-c icloud
我正在使用iCloud Key Value存储的OSX 10.8应用程序.它并没有使用文件存储.
我想确定iCloud Key Value商店是否可供用户使用.
我试图像使用云一样:
+ (BOOL)isCloudAvailable {
id currentCloudToken = [NSFileManager defaultManager] ubiquityIdentityToken];
return (currentCloudToken) ? YES : NO;
}
Run Code Online (Sandbox Code Playgroud)
但是,ubiquityIdentityToken即使用户登录到iCloud ,调用始终返回nil.
如果我配置Ubiquity容器以及键值存储,那么该调用确实有效.
但是,我刚刚让我的应用程序被Apple评论拒绝,表明我需要"文档和数据存储"而不需要在应用程序中使用它.我只是用它来确定iCloud是否可用.
无论如何要确定用户是否可以单独使用iCloud键值存储?
Tho*_*ing 11
The iCloud Fundamentals guide has a table that compares Document Storage to the Key-Value Store(Table 1-1). In contrary to Mobile Documents, the Key Value Store should be considered Always effectivly available.
The [NSUbiquitousKeyValueStore defaultStore] also isn't nil when iCloud is not enabled, and it even stores key/value pairs - It just doesn't upload them to the iCloud server.
From the NSUbiquitousKeyValueStore's point of view there is little difference between offline and logged-out.
您还必须记住,只要设备连接到帐户,就会将已存储的值推送到服务器.可能有必要处理冲突(如果默认的last-one-wins策略不适用于您的用例).