如何仅使用NSUbiquitousKeyValueStore以编程方式检测用户设备上是否启用了iCloud? [英] How to programmatically detect if the iCloud is enabled on user's device when only use NSUbiquitousKeyValueStore?

查看:101
本文介绍了如何仅使用NSUbiquitousKeyValueStore以编程方式检测用户设备上是否启用了iCloud?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 NSUbiquitousKeyValueStore 将某些偏好数据同步到iCloud。我发现如果用户在设置应用程序中禁用iCloud的文档和数据项, NSUbiquitousKeyValueStore 无法将其数据同步到iCloud。所以,我想首先检查此设置是否已打开。我找到了这段代码片段:

I am using NSUbiquitousKeyValueStore to sync some preference data to iCloud. I found that if the user disable "Document & Data" item of iCloud in "Setting App", NSUbiquitousKeyValueStore can not synchronize its data to iCloud. So, I want to first check if this setting is switched on. I found this Code snippet:

    NSURL *ubiq = [[NSFileManager defaultManager] 
                   URLForUbiquityContainerIdentifier:nil];
    NSLog(@"url=%@",ubiq);
    if (!ubiq) {
        UIAlertView *av = [[UIAlertView alloc] initWithTitle:nil message:@"Please enable iCloud in Setting app" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [av show];
        return;

    }

我想知道的是这是否是唯一的方法检测,即使我只使用 NSUbiquitousKeyValueStore (不是iCloud文档存储)。还有更好的选择吗?

What I want to know is whether this is the only way to detect, even if I just use NSUbiquitousKeyValueStore (not iCloud document storage). Is there a better alternative?

推荐答案

基本上, NSUbiquitousKeyValueStore 始终可用即使用户没有iCloud帐户(在这种情况下, NSUbiquitousKeyValueStore 只是一个简单的本地存储)。因此,一般情况下,您无需询问自己或用户是否配置了iCloud帐户。

Basically, NSUbiquitousKeyValueStore is always available, even if the user does not have an iCloud account (in this case, NSUbiquitousKeyValueStore is just a simple local storage). So in general, you don't need to ask yourself or the user if there is a configured iCloud account.

如果您确实想知道,请在iOS 5中,唯一的解决方案是你提到的那个。

If you really want to know for sure, in iOS 5, the only solution is the one you're mentioning.

这篇关于如何仅使用NSUbiquitousKeyValueStore以编程方式检测用户设备上是否启用了iCloud?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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