title: How to copy file in iCloud to app sandbox using File Manager
body: <p>I have a file in the Cloud 15.2 kb. I cannot copy it back to the app sandbox. My code is listed below. Any help is appreciated</p>
  
  <pre><code>    NSURL *ubiq = [[NSFileManager defaultManager]
                     URLForUbiquityContainerIdentifier:nil];
  if (ubiq)
      {
      NSError *error = nil;
      NSFileManager *fileManager = [NSFileManager defaultManager];
      NSURL *cloudContainerURL = [fileManager URLForUbiquityContainerIdentifier:nil]:
      NSURL*dirURL=[cloudContainerURL URLByAppendingPathComponent:@"Documents" isDirectory:YES];
      [fileManager createDirectoryAtURL:dirURL withIntermediateDirectories:NO  attributes:nil error:&amp;error];
       NSURL *icloudURL = [dirURL URLByAppendingPathComponent:@"Passwords File.txt"];
  
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsPath = [paths objectAtIndex:0];
  
      // Destination path
      NSString *fileInDocumentsPath = [documentsPath  stringByAppendingPathComponent:@"Passwords File.txt"];
       NSURL* sandboxDocumentURL = [NSURL fileURLWithPath:fileInDocumentsPath];
  
    [[ NSFileManager defaultManager ] copyItemAtURL:icloudURL toURL:sandboxDocumentURL error:&amp;error ];
  </code></pre>