我需要在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(“/ private / var / mobile / Library / Mobile 文档/ 6CVKW284XZ〜COM〜cloudmy〜ROM /文档/ folder_20120209_194803 /(A 文件被保存由klp)“),它没有返回0,并且设置了errno 到2。
答案 0 :(得分:0)
您可能需要转义文件名中的空格字符,如:
"(A\ Document\ Being\ Saved\ By\ klp)"