There's an example here:
http://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/iCloud/iCloud.html#//apple_ref/doc/uid/TP40007072-CH5-SW17
Every user with an Apple ID receives a free iCloud account but some users might choose not to enable iCloud for a given device. Before you try to use any other iCloud interfaces, you must call the URLForUbiquityContainerIdentifier: method to determine if iCloud is enabled. This method returns a valid URL when iCloud is enabled (and the specified container directory is available) or nil when iCloud is disabled.
The first time you call the URLForUbiquityContainerIdentifier: method for a given container directory, iOS extends your application sandbox to include that container directory. Thus, it is important that you call this method at least once to ensure that iCloud is enabled and that your main container directory is accessible. And if your application accesses multiple container directories, you should call the method once for each directory.
It implies it should return nil
if the directory isn't available in iCloud.
The NSFileManager
doc also has this:
containerID [...] If you specify nil, this method returns the first container listed in the com.apple.developer.ubiquity-container-identifiers entitlement.
Return Value
A URL pointing to the specified container directory or nil if the container could not be located or if iCloud storage is unavailable for the current user or device.
The entitlement setting may include the first path by default.