When in airplane mode or any other state where network access is not available, will a call to NSFileManager's URLForUbiquityContainerIdentifier:
return nil?
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?
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!
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");
}
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.
Here is a great article on iCloud setup. http://www.raywenderlich.com/6015/beginning-icloud-in-ios-5-tutorial-part-1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With