简体   繁体   中英

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..

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. 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. It will therefore be a different absolute path, but this should be irrelevant to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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