Home > DeveloperSection > Forums > Best way to find the user's Documents directory on an iPhone
naomi burke
naomi burke

Total Post:28

Posted on    September-08-2015 1:37 AM

 iPhone iPhone  Ios  Objective C 

 1 Reply(s)
 507  View(s)
Rate this:

I have read an iPhone book there i find the user's Documents directory is with the code:

[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];


but that seems slightly brittle, and dissimiliar to the normal Mac way of doing it, which would be:

NSSearchPathForDirectoriesInDomains(NSDocumentsDirectory, NSUserDomainMask, YES);


Is there any particular reasons to use one over the other?

Jessica James
Jessica James

Total Post:16

Posted on    September-08-2015 11:45 PM

Here is the code that I use in my framework.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];


Don't want to miss updates? Please click the below button!

Follow MindStick