Does URLForUbiquityContainerIdentifier: return nil have when network access is unavailable?

When in airplane mode or in any other state where network access is unavailable, there will be a call to NSFileManager URLForUbiquityContainerIdentifier: return nil?

The next question is: if this call to URLForUbiquityContainerIdentifier: does not return zero, but rather returns a valid URL when network access is unavailable, is this a way to access cloud-based documents offline?

Apple docs says it will return nil if iCloud is not configured or enabled. He does not mention what happens if network access is not available.

I would experience it myself, but from the fact that, as I understand it, I would have to test it on a real device, and testing on the device is currently impossible for me. Thanks!

+6
source share
1 answer

UbiquityContainer is a local storage container that contains documents requested from iCloud. This container is available when there is no network. 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"); } 

You can access files and the ubiquitous container when the phone is even on the plane. When network connections are restored, the icloud daemon will automatically sync files even in the background.

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

+5
source

Source: https://habr.com/ru/post/907135/


All Articles