title: iCloud Drive - Read & Write (NSData)
body: <p>Trying to save custom objects as NSData then upload to iCloud <strong>Drive</strong></p>
  
  <p>any direction?
  I tried already the Key-Value Method, but it is limited for 1MB :/</p>
  
  <p><strong>is it the correct way?</strong>
  if yes, how can I read from the iCloud path?</p>
  
  <pre><code>+(void)iCloudWrite:(NSData*)data
  {
  
      NSURL* ubiq = [[NSFileManager defaultManager]URLForUbiquityContainerIdentifier:nil];
      NSURL *ubiquitousPackage = [[ubiq URLByAppendingPathComponent:@"Documents"]  URLByAppendingPathComponent:@"iCloudHistory.zip"];
  
      MyDocument *mydoc = [[MyDocument alloc] initWithFileURL:ubiquitousPackage];
      mydoc.dataContent = data;
  
      [mydoc saveToURL:[mydoc fileURL] forSaveOperation:UIDocumentSaveForOverwriting completionHandler:^(BOOL success)
       {
           if (success)
           {
               NSLog(@"Synced with icloud");
           }
           else
               NSLog(@"Syncing FAILED with icloud");
       }];
  }
  </code></pre>
  
  <p>EDITED:</p>
  
  <p><a href="https://i.stack.imgur.com/Rv3QD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rv3QD.png" alt="enter image description here"></a></p>