I am currently using local storage in my iOS App. The user data is stored in the Document Directory and now I am planning to use iCloud Documents storage instead.

Here is how I intend to do it :

1. Checking if iCloud is available on the device
2. If yes, use URLForUbiquityContainerIdentifier to get the iCloud container URL
3. Save new files and documents to this new URL

For that I am using this code that will return the URL of the document folder (iCloud or local)

```
class CloudDataManager {

    class func getDocumentDiretoryURL() -> NSURL {
        let localDocumentsURL = NSFileManager.defaultManager().URLsForDirectory(NSSearchPathDirectory.DocumentDirectory, inDomains: .UserDomainMask).last! as NSURL
        let iCloudDocumentsURL = NSFileManager.defaultManager().URLForUbiquityContainerIdentifier(nil)?.URLByAppendingPathComponent("Documents")

        if userDefault.boolForKey("useCloud") && iCloudDocumentsURL != nil  {
            return iCloudDocumentsURL!
        } else {
            return localDocumentsURL
        }
    }
}

```

Is it the best practice? 
I am worried problems will occur if one day iCloud isn't available so the local directory will be used instead of the cloud container and will be empty.
Thank you.