确定iCloud Key值存储的可用性 [英] Determine availability of iCloud Key Value Store

查看:230
本文介绍了确定iCloud Key值存储的可用性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用iCloud Key Value store的OSX 10.8应用程式。

I am working on OSX 10.8 application that uses iCloud Key Value store. It does not use Document storage.

我想确定iCloud Key Value存储是否可供用户使用。

I would like to determine if iCloud Key Value store is available for a user.

我试图使用云:

+ (BOOL)isCloudAvailable {
       id currentCloudToken = [NSFileManager defaultManager] ubiquityIdentityToken];
       return (currentCloudToken) ? YES : NO;
}

但是,调用 ubiquityIdentityToken 总是返回nil,即使用户登录到iCloud。

However, the call to ubiquityIdentityToken always returns nil, even when a user is logged into iCloud.

如果我配置Ubiquity容器以及键值存储,那么该调用会工作。

If I configure a Ubiquity Container as well as the key-value store then that call does work.

但是,我刚刚发现我的应用程序被苹果审查拒绝,表示我需要文档和数据存储,而没有在应用程序中的任何要求。我只是使用它来确定是否iCloud可用。

However, I've just had my app rejected by Apple review for indicating I need "Document & Data storage" without having any requirement in the app for it. I was simply using it to determine if iCloud was available.

是否还有确定是否单独的iCloud键值存储可用于用户?

Is there anyway to determine if iCloud key-value store alone is available to a user?

推荐答案

iCloud基础指南中有一个表格,其中将文档存储与键值存储比较(表1-1)。

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.

[NSUbiquitousKeyValueStore defaultStore]与「移动文件」相反,当iCloud没有被启用,它甚至存储键/值对 - 它只是不上传他们到iCloud的也不是 nil 服务器。
从NSUbiquitousKeyValueStore的角度来看,离线和已注销之间没有什么区别。

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策略对您的用例不起作用)。

You also have to keep in mind that already stored values are pushed to the server as soon as the device attaches to the account. It might be necessary to handle conflicts (if the default last-one-wins strategy doesn't work for your use case).

这篇关于确定iCloud Key值存储的可用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆