tags:

views:

1513

answers:

1

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?

+5  A: 

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.

Jason Coco