【问题标题】:Restoring icloud data to app将 icloud 数据恢复到应用程序
【发布时间】:2013-06-07 06:36:59
【问题描述】:

在我的应用程序中,我成功地将我的数据同步到 iCloud,即使我可以看到该文件的 iCloud 设置。但现在我不知道如何将该文件从 iCloud 恢复到我的应用程序。

请帮我找回那个文件

【问题讨论】:

  • ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; NSURL *file = [[ubiq URLByAppendingPathComponent:@"Documents" isDirectory:true] URLByAppendingPathComponent:@"filename"];
  • @CaptainRedmuff 一些我发现并尝试过但无法正常工作的地方

标签: ios objective-c icloud


【解决方案1】:

文档已经存在于您想要的位置。你只需要做正确的事情来访问它。使用您从代码中获取的 URL,但不要将最后一部分包含在 @"filename" 中。

将url传递给文件管理器上的这个方法:

  • (NSArray *)contentsOfDirectoryAtURL:(NSURL *)url包括PropertiesForKeys:(NSArray )keys选项:(NSDirectoryEnumerationOptions)掩码错误:(NSError *)error

NSArray 包含指向该目录中的文件和文件夹的 NSURL 对象。使用所需文件的 URL 并根据需要打开它。有关详细信息,请参阅 NSFileManager 文档。

【讨论】:

  • NSURL * ubiq = [[NSFileManager defaultManager]URLForUbiquityContainerIdentifier:nil]; // NSURL * ubiquitousPackage = [ubiq URLByAppendingPathComponent:DairiesListFilePath]; NSURL * ubiquitousPackage = [[ubiq URLByAppendingPathComponent:@"Documents"] URLByAppendingPathComponent:@"filename.csv"]; 使用这些 url 我试图取回这些文件
  • 不过,无需手动创建这些 URL。如果您使用我列出的方法,那么它将为您提供所需的所有 URL 的数组。还是我误会了什么?
猜你喜欢
  • 2015-11-05
  • 1970-01-01
  • 2014-01-29
  • 2016-01-19
  • 2015-05-14
  • 2015-07-30
  • 1970-01-01
  • 2020-09-03
  • 1970-01-01
相关资源
最近更新 更多