Search code examples
iphoneiosnsdatansfilemanager

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.


Solution

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