The morning after

Monday, March 22, 2010

iPhone Simulator base directory

I wanted to know where the iPhone Simulator application was writing files, e.g. after a call to NSArray.writeToFile:atomically:
I figured out that the path is constructed from several variables:
/Users/<name>/Library/Application Support/iPhone Simulator/<version>/Applications/<uuid>
In the previous path just replace the following placeholders:
  • <name>
    The name of the current user
  • <version>
    The iPhone version the simulator is targeting
  • <uuid>
    A universally unique identifier, e.g. FF816B31-D171-4CC1-8E20-B0833229BEDB
In this path you'll typically find a Documents directory, files should go in there ... use the following code to get a reference to that path, the first element points to that directory which should be used as the root of your application's storage:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

0 Comments:

Post a Comment

<< Home