简体   繁体   English

在模拟器和实际iOS设备上存储文件

[英]Storing files on simulator vs actual iOS device

Currently I am storing some mp3 files locally on a simulator using the following code to obtain a path.. 目前,我正在使用以下代码在模拟器上本地存储一些mp3文件,以获取路径。

manager = [NSFileManager defaultManager];
    NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    filePath = [paths objectAtIndex:0];

This storage method works fine on the simulator, but when I examine the actual path in the debugger, it ends up being a path on my macbook where the simulator is storing its data. 这种存储方法在模拟器上可以正常工作,但是当我在调试器中检查实际路径时,它最终成为了我的Macbook上模拟器用来存储其数据的路径。 Does anyone know if this code will also work on an actual device? 有人知道该代码是否也可以在实际设备上运行吗? Will a different path be generated that is specific to the target device? 是否会生成特定于目标设备的其他路径? Thanks. 谢谢。

Of course this code should be fine, NSFileManager will manage this for you, on the iPhone device this will resolve to your applications sandbox. 当然,此代码应该没问题, NSFileManager将为您管理此操作,在iPhone设备上,它将解析为您的应用程序沙箱。 It will therefore be a different absolute path, but this should be irrelevant to you. 因此,这将是一条不同的绝对路径,但这与您无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM