URLForUbiquityContainerIdentifier:网络访问不可用时返回nil吗? [英] Does URLForUbiquityContainerIdentifier: return nil when network access is not available?

查看:254
本文介绍了URLForUbiquityContainerIdentifier:网络访问不可用时返回nil吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当处于飞行模式或网络访问不可用的任何其他状态时,将调用NSFileManager的 URLForUbiquityContainerIdentifier:返回nil?

When in airplane mode or any other state where network access is not available, will a call to NSFileManager's URLForUbiquityContainerIdentifier: return nil?

对此的跟进问题是:如果此次调用 URLForUbiquityContainerIdentifier:不返回nil而是返回网络访问不可用时的有效URL是否可以离线访问基于云的文档?

A follow up question to this is: if this call to URLForUbiquityContainerIdentifier: DOES not return nil but rather returns a valid URL when network access is not available is this a way to access cloud based documents offline?

苹果文档声明如果iCloud将返回nil未配置或未启用。它没有提到如果没有网络访问会发生什么。

The apple docs state that this will return nil if iCloud is not configured or not enabled. It does not mention what will happen if network access is not available.

我会自己测试一下,但据我所知,我必须在实际设备上进行测试目前我无法在设备上进行测试。谢谢!

I would test this myself but from what I understand I would have to test this on an actual device and testing on a device is not possible for me at this time. Thank you!

推荐答案

UbiquityContainer是一个本地存储容器,包含您从iCloud请求的文档。当网络没有时,此容器可用。通过使用以下示例

The UbiquityContainer is a local storage container that contains the documents you requested from iCloud. This container is available when when the network is not. By using the following example

NSURL *ubiq = [[NSFileManager defaultManager] 
  URLForUbiquityContainerIdentifier:nil];
if (ubiq) {
    NSLog(@"iCloud access at %@", ubiq);
    // TODO: Load document... 
} else {
    NSLog(@"No iCloud access");
}

手机均匀时,您将可以访问文件和普遍存储容器在飞机模式。当网络连接恢复时,icloud守护程序将自动同步文件,即使在后台也是如此。

You will be able to access the files and ubiquity container when the phone is even in airplane mode. When the network connections restore the icloud daemon will automatically sync the files even in the background.

这是一篇关于iCloud设置的精彩文章。
http://www.raywenderlich.com/6015/开始-icoloud-in-ios-5-tutorial-part-1

Here is a great article on iCloud setup. http://www.raywenderlich.com/6015/beginning-icloud-in-ios-5-tutorial-part-1

这篇关于URLForUbiquityContainerIdentifier:网络访问不可用时返回nil吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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