Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with NSSearchPathForDirectoriesInDomains

I am trying to work directories. Unfortunately i get a non-writeable directory when I run NSSearchPathForDirectoriesInDomains. What I get is:

/Users/me/Library/Application Support/iPhone Simulator/User/Documents

When I run other people's examples I get:

/Users/me/Library/Application Support/iPhone Simulator/User/Applications/6958D21C-C94B-4843-9EF1-70406D0CA3A3/Documents

which is writeable.

The snippet of the code used is

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSLog(documentsDirectory);

What do I need to do allow me to get the same long directory structure?

like image 958
John Smith Avatar asked Jul 23 '09 19:07

John Smith


2 Answers

That long path with the GUID is the documents path for your app, and is expected behavior.

Not sure what your code looks like, but getting the path to your app's document directory should be something like:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

(From Mark/LaMarche p. 331)

like image 105
Kevin L. Avatar answered Nov 09 '22 15:11

Kevin L.


since it searches for the "object at index:0"

NSString *documentsDirectory = [paths objectAtIndex:0];

there could be a directory starting with a letter smaller than "d" for documents. Which becomes the "object at index:0". I know this might not be possible but It could be true as well.

like image 38
fargo Avatar answered Nov 09 '22 15:11

fargo