A copy of Icloud receives the error Domain = NSCocoaErrorDomain Code = 512

When I copy a file from a local application to iCloud, the file is copied, but I got this error: Domain Error = NSCocoaErrorDomain Code = 512 "Operation could not be completed. (Cocoa error 512.)"

Here is the code

NSString *source = [tagsPath stringByAppendingPathComponent:current_Group_Name]; source = [source stringByAppendingPathComponent:fileName]; NSURL *sourceURL = [NSURL fileURLWithPath:source]; dispatch_queue_t q_default; q_default = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(q_default, ^(void) { fileManager = [NSFileManager defaultManager]; NSURL *ubiq = [fileManager URLForUbiquityContainerIdentifier:nil]; if (ubiq) { NSURL *groupURL = [tagsURL URLByAppendingPathComponent:current_Group_Name]; NSError *error= nil; NSURL *destinationURL = [groupURL URLByAppendingPathComponent:fileName]; [fileManager setUbiquitous:YES itemAtURL:sourceURL destinationURL:destinationURL error:&error]; if (error != nil) { NSLog( @"Error > %@",error); [self displayError:NSLocalizedString(@"XMP file not saved in iCloud.", @"") withReason:[NSString stringWithFormat:@"%@%d",NSLocalizedString(@"Error code : ", @""),[error code]]];} dispatch_queue_t q_main = dispatch_get_main_queue(); dispatch_async(q_main, ^(void) { }); }); 

Any suggestions?

thanks

+4
source share
2 answers

this only happens to me on iOS6 devices, it’s strange that it actually looks like saving, when I upload my data to save, the only problem is that if I delete the application and then restart it, it seems to destroy the data icloud

+1
source

I also use the same code

 setUbiquitous:YES itemAtURL:sourceURL destinationURL:destinationURL error:&error]; 

to move the file to iCloud and at that time I also got the same error, but I finally decided that with a small change in code like this

 [[[NSFileManager alloc]init]setUbiquitous:YES itemAtURL:ubiquitousPackage destinationURL:localurl2 error:&error]; 
0
source

Source: https://habr.com/ru/post/1438867/


All Articles