我需要在iCloud中创建具有某些文件的文件夹。尝试以下操作:使用文件创建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)
{
}
}];
它会返回错误:
Foundation called mkdir("/private/var/mobile/Library/Mobile Documents/6CVKW284XZ~com~cloudmy~rom/Documents/folder_20120209_194803/(A Document Being Saved By klp)"), it didn't return 0, and errno was set to 2.
您没有创建文件夹,而是没有扩展名的文件。 – 2012-10-27 22:10:57