views:

1417

answers:

2

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?

+1  A: 

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)

Kevin L.
That's what I have done. Here is the portion. I have also written a skeleton app from scratch and I get the same problem.NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSLog(documentsDirectory);
John Smith
I have clarified my question with the code snippet. This is a real mystery to me.
John Smith
+1  A: 

Looks like this is a duplicate of this post.

A comment there notes that this is caused by a provisioning issue.

Ben Lachman