我需要在iCloud中创建包含一些文件的文件夹。尝试以下操作:
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)
{
}
}];
它返回错误:
“MKDIR基金会”(“私人/ VAR/移动/图书馆/莫比尔”)
documents/6cvkw284xz~com~cloudmy~rom/documents/folder_20120209_194803/(一个
“正在由klp保存的文档)”,它没有返回0,并且设置了errno
到2。
最佳答案
您可能需要转义文件名中的空格字符,如:
"(A\ Document\ Being\ Saved\ By\ klp)"
是吗?