gpt4 book ai didi

objective-c - 使用文件创建 iCloud 文件夹

转载 作者:搜寻专家 更新时间:2023-10-30 19:49:49 25 4
gpt4 key购买 nike

我需要在 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.

最佳答案

您可能需要转义文件名中的空格字符,如:

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

?

关于objective-c - 使用文件创建 iCloud 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9214150/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com