Creating iCloud folders with files

I need to create folders with some files in iCloud. Try the following:

NSString *folderName = [NSString stringWithFormat:@"folder_%@", [formatter stringFromDate:[NSDate date]]]; //iCloud folder NSURL *ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; NSURL *ubiquitousPackage = [[[ubiq URLByAppendingPathComponent:@"Documents"] URLByAppendingPathComponent:folderName]URLByAppendingPathComponent:@"file.txt"]; //NSLog(@"%@",ubiquitousPackage.relativePath); File *doc = [[File alloc] initWithFileURL:ubiquitousPackage]; [doc saveToURL:[doc fileURL] forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) { if (success) { } }]; 

It returns an error:

The fund is called mkdir ("/ private / var / mobile / Library / Mobile Documents / 6CVKW284XZ ~ com ~ ~ cloudmy rum / Documents / folder_20120209_194803 / (A Document saved by klp)"), it did not return 0, and errno was installed before 2.

+4
source share
1 answer

You may need to avoid the space character in your file name, for example:

 "(A\ Document\ Being\ Saved\ By\ klp)" 

?

0
source

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


All Articles