docPath() code not working -- /tmp does


#1

I’m using Xcode 5.0.2 and iPhone Simulator 7.03.

Something doesn’t seem to be working with the the datePath() function, in that it returns a directory which does not exist. That is, the code:

NSString *docPath() { NSArray *pathList = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES); NSLog(@"%@", [pathList objectAtIndex:0]); return [[pathList objectAtIndex:0] stringByAppendingPathComponent:@"data.td"]; }

logs this: —> DocPath: /Users/david/Library/Application Support/iPhone Simulator/7.0.3/Applications/84F8396F-88CF-4A56-AA68-6E497DA457C6/Library/Documentation

That path doesn’t exist on my Mac. The real file structure has […]/Library/Library/Documentation and at no point is a data.td file created in it, and so of course there is no persistence of data once the simulator is closed.

I know the rest of the code works, because if I change docPath() to @"/tmp/data.td" the data.td file is created and persists over a rebuild/rerun of the program.

The documentation for NSSearchPathForDirectoriesInDomains says that the directory returned might not exist – but why does it seem to work for other posters and not for my configuration? Is this simply a matter of my using a later version?


#2

it’s probably because you are using NSDocumentationDirectory instead of NSDocumentDirectory.


#3

Thank you very much for that – I’d read the code several times and thought I’d cross checked it accurately. Must have accepted the wrong automatic entry.

Many thanks!