BEST WAY TO FIND THE USER'S DOCUMENTS DIRECTORY ON AN IPHONE

naomi burke

Total Post:28

Points:196
Posted by  naomi burke
 799  View(s)
Ratings:
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?

  1. Jessica James

    Post:16

    Points:114
    Re: Best way to find the user's Documents directory on an iPhone

    Here is the code that I use in my framework.

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

    NSString *documentsDirectory = [paths objectAtIndex:0];

     

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!