1

我知道以前有人问过这个问题,但到目前为止,我发现的帖子都没有解决我的问题。

这是我的代码

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);
       }
});

我收到错误,我不知道如何解决它。希望有人可以帮助我:(

    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. 
4

1 回答 1

-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.

于 2013-08-20T23:28:17.050 回答