【问题标题】:Find Downloaded File in iPhone Documents folder through iTunes通过 iTunes 在 iPhone Documents 文件夹中查找下载的文件
【发布时间】:2014-02-01 06:16:03
【问题描述】:

我是 iOS 新手,刚开始学习。我创建了一个应用程序,用于将文件下载到目录的 Documents 文件夹中。当我在模拟器上下载文件时,我可以通过以下路径找到它:/Users/......./Simulator/iOS7.0/Applications/Documents。 但是当我在设备上运行应用程序并下载文件时,我无法找到这些文件。我已经使用以下代码给出了路径:

filePath = [NSHomeDirectory() stringByAppendingPathComponent: [NSString stringWithFormat: @"Documents/%@", self.downloadedFilename]];    

谁能告诉我如何使用 iTunes 在设备上查找文件?

【问题讨论】:

    标签: ios iphone path itunes


    【解决方案1】:

    将沙盒中的所有文件下载到您的 Mac 上怎么样?打开 Xcode,Window->Organizer。

    单击已连接设备的应用程序条目,然后单击应用程序列表中的应用程序。现在您可以在设备上查看该应用的数据文件,并且可以将整个捆绑包从设备下载到您的 Mac。

    【讨论】:

      【解决方案2】:

      使用下面的示例代码在创建的文件夹文档中创建和写入数据

      NSData *data = [[NSData alloc] initWithBytes:saves length:4]; //replace with your file content
      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
      NSString *documentsDirectory = [paths objectAtIndex:0];
      NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/MyFolder"];
      
      if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])
          [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error];
      NSString *appFile = [dataPath stringByAppendingPathComponent:@"MyFile"];
      [data writeToFile:appFile atomically:YES];
      

      更新:在将它与 itunes 连接之前,您是否在 info.plist 中检查过这个布尔值? Check this bool in your info.plist to share files with itunes.Refer UIFileSharingEnabled 看看下面这张图。

      【讨论】:

      • 感谢您的回复。但这不是我面临的问题。实际上,我也可以下载所需路径中的文件,但问题是当我通过设备而不是模拟器下载文件时,我无法找到这些文件。我尝试通过iTunes查找下载的文件,但找不到。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 2012-07-23
      • 2011-12-07
      • 1970-01-01
      相关资源
      最近更新 更多