【问题标题】:Create iCloud folders with files使用文件创建 iCloud 文件夹
【发布时间】:2012-03-02 02:49:33
【问题描述】:

我需要在 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 的基金会 Documents/6CVKW284XZ~com~cloudmy~rom/Documents/folder_20120209_194803/(A 文档被 klp)") 保存,它没有返回 0,并且设置了 errno 到 2.

【问题讨论】:

  • 您创建的不是文件夹,而是没有扩展名的文件。

标签: objective-c icloud


【解决方案1】:

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

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

?

【讨论】:

  • 不工作。我在文件系统上创建了目录 folder_20120209_194803 并且都保存好了。但是现在我无法获取文件夹。
猜你喜欢
  • 2017-07-03
  • 1970-01-01
  • 2010-10-09
  • 2017-07-14
  • 2015-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多