Martin Cote
Martin Cote

Reputation: 29852

Is the NSDocumentDirectory unique for a given application?

I would like to save some user-specific data in my iPhone app. I was looking at the SQLite sample, and it is using something similar to this:

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

What I would like to know is, is "writableDBPath" unique for my app? Is there a risk that my "dbName" will clash with another file of the same name used by another app?

Upvotes: 3

Views: 3691

Answers (1)

Jason Coco
Jason Coco

Reputation: 78363

On the iPhone, they are unique because of the application sandboxing that's done. On a regular mac, however, the NSDocumentDirectory is only unique to a user and if you don't make the file somehow unique or creating an application-specific sub-directory, you could get a name clash, so just be careful of that if you ever go from iPhone to Mac.

Upvotes: 6

Related Questions