1

I know this question has been asked before but so far none of the posts that I found solve my problem.

Here's my codes

NSURL *ubiquitousPackage = [[ubiq URLByAppendingPathComponent:
                                     @"Documents"] URLByAppendingPathComponent: kCloudStorageFileName];

CloudDocument *doc = [[[CloudDocument alloc] initWithFileURL:ubiquitousPackage] autorelease];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^
{
       NSError* error = [[[NSError alloc] init] autorelease];
       if ([[NSFileManager defaultManager] setUbiquitous: true itemAtURL: [doc fileURL] destinationURL: ubiquitousPackage error: &error])
       {
          NSLog(@"Moved Cloud successfully");
       }
       else
       {
          NSLog(@"Error: %@", error);
       }
});

I'm getting error and I don't know how to fix it. Hope someone can help me out :(

    Error Domain=NSCocoaErrorDomain Code=512 "The operation couldn’t be completed. (Cocoa error 512.)"
 UserInfo=0x1f82a3b0 
{NSURL=file://localhost/private/var/mobile/Library/Mobile%20Documents/QR39Z776YC~com~something~testApp/Documents/cloudSavedData.doc, NSUnderlyingError=0x1f82a820 "
The operation couldn’t be completed. 
Lebyrt
  • 1,376
  • 1
  • 9
  • 18
Cadrick Loh
  • 721
  • 1
  • 7
  • 19

1 Answers1

-1

If the file already exists you shouldn't be calling setUbiquitous on it. Use [NSFileManager isUbiquitousItemAtURL:] to determine if it's already in iCloud.

Dave Teare
  • 509
  • 3
  • 7