Sunday, 13 March 2011

Documents Directory File Path - iPhone, iPad, iOS Development

Getting the file path to the documents directory is very simple however the documentation in this area can be rather confusing.

Firstly you call the function NSSearchPathForDirectoriesInDomains(). This function returns an array however there will almost always only be one object within the array.

 NSArray * NSSearchPathForDirectoriesInDomains (  NSSearchPathDirectory directory,  NSSearchPathDomainMask domainMask,  BOOL expandTilde );

The reference for the method is shown above.
The Directory value must be one of the predefined search path directories of the operating system. The most commonly used directory and the one we'll use here is the documents directory which the value for is NSDocumentDirectory.  
Other values can be seen in the documentation here.
The domain mask value is most often NSUserDomainMask meaning the returned path is local to the user's home directory.  Other possible values are shown below.
 NSUserDomainMask - Local to the user's home directory.
 NSLocalDomainMask - local to the current machine.
 NSNetworkDomainMask - Publicly available location in the local area network.
 NSSystemDomainMask - /System (Usually unused private).
 NSAllDomainsMask - will return a path for each of the above domains.
The full example of how to obtain a string of the system file path to the user documents directory is shown below.
 -(NSString *)documentsDirectoryPath {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
return documentsDirectoryPath;
}

49 comments:

  1. Hello,
    The first thing you should do when looking to hire a freelance iPhone developer is to outline what type of development you need done for the iPhone.
    hire iphone Developer

    ReplyDelete
  2. I posted a question on StackOverflow about NSSearchPathForDirectoriesInDomains - it's returning the wrong directory. Do you know why this would be happening? http://stackoverflow.com/questions/6515979/nssearchpathfordirectoriesindomains-returns-the-wrong-directory

    ReplyDelete
  3. I have read this post. collection of post is a nice one ..that am doing website designing company chennai india and website development company chennai india. That I will inform about your post to my friends and all the best for your future posts..

    ReplyDelete
  4. Now day's demand of iPhone application is increasing very fast. This is the appropriate blog for any iPhone developer who wants to outsource their iPhone application development.

    ReplyDelete
  5. Thanks For Sharing This Post

    For More Information You Can Visit This Website iPhone Application Development Solutions

    ReplyDelete
  6. Nice Post ..!! I really i like the way of your writing this post. You have shared a very interesting and informative post about Mobile platform .. keep Updating..!!
    Android Application Development

    ReplyDelete
  7. If you are searching for cost effective as well as solid Mobile Application Development Services and Web Development in India provider then without thinking much you can choose to hire the services offered by Acetech. We are one of the leading companies offering affordable, timely and quality mobile apps services.

    ReplyDelete
  8. Today all users crazy about new iphone apps and iPhone become more necessary for people even businesspersons. If you want to development customs, iphone application development then must hire a well-reputed development company.

    ReplyDelete
  9. Great article ...Thanks for your great information, the contents are quiet interesting. I will be waiting for your next post.
    iphone app development usa

    ReplyDelete
  10. I am glad after reading your technical blog... Your blog is excellent & you are helping others by posting these type of articles publicly... Appreciated
    biggest iphone apps development company

    ReplyDelete
  11. Thanks for giving knowledge Excellent overview :)
    android developer USA

    ReplyDelete
  12. Thanks so much for such a useful collection. And i must tell you guys , it is worth visiting our page for more relevant information and iphone apps development works and services.. http://www.siliconithub.com/mobile-apps-developer/iphone-application-development.html

    ReplyDelete

  13. Really nice information you had posted. Its very informative and definitely it will be useful for many people
    iOS Training in Chennai
    Android Training in Chennai
    php Training in Chennai

    ReplyDelete
  14. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..

    Mobile App Development Company in Chennai
    Android app Development Company in Chennai
    ios app development Company in Chennai

    ReplyDelete
  15. "Beautiful Blog. Great content."!!
    "Really nice and awesome "!!


    mobile app development for android

    ReplyDelete
  16. It's interesting that many of the bloggers your tips helped to clarify a few things for me as well as giving.. very specific nice content. And tell people specific ways to live their lives.Sometimes you just have to yell at people and give them a good shake to get your point across.
    Mobile App Development Company
    Android app Development Company
    ios app development Company
    Mobile App Development Companies

    ReplyDelete
  17. We are also providing best mobile solutions, web design and development, ecommerce solution, SEO.
    Check out us here
    Web Design company in Hubli | web designing in Hubli | SEO company in Hubli

    ReplyDelete
  18. You have provided an nice article, Thank you very much for this one. And i hope this will be useful for many people.. and i am waiting for your next post keep on updating these kinds of knowledgeable things...

    Mobile App Development Company
    Mobile App Development Company
    Mobile app Development Companies

    ReplyDelete
  19. Thank you for taking the time to publish this information very useful!
    sell used cellphones

    ReplyDelete
  20. These ways are very simple and very much useful, as a beginner level these helped me a lot thanks fore sharing these kinds of useful and knowledgeable information.
    Android App Development Company

    ReplyDelete
  21. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  22. it is really amazing...thanks for sharing....provide more useful information...
    Mobile app development company

    ReplyDelete
  23. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Fitness SMS
    Salon SMS
    Investor Relation SMS

    ReplyDelete
  24. This article is very much helpful and i hope this will be an useful information for the needed one. Keep on updating these kinds of informative things...

    iOS App Development Company

    ReplyDelete
  25. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  26. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Texting API
    Text message marketing
    Digital Mobile Marketing
    Sms API
    Sms marketing

    ReplyDelete
  27. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Sms marketing
    Text message marketing
    Fitness SMS

    ReplyDelete
  28. That's wonderful stuff you've written up here. Been searching for it all around. Great blogWebsite Designing Company Bangalore | Web Development Company Bangalore

    ReplyDelete
  29. Extremely interesting! Much obliged additionally to share the blog. Extremely helpful to comprehend the impact of iOS Training in Ahmedabad
    Iphone Training in Ahmedabad
    Live ios Project Training in Ahmedabad

    ReplyDelete
  30. Great Post, I really appreciate your effort here. We could surely use it for some help. In addition I would like to share an article: How Much Does it Cost to Develop an Android Application. I think this can be of some help in calculating the cost of your android apps.

    ReplyDelete
  31. Found your post interesting to read. I cant wait to see your post soon. Good Luck for the upcoming update.This article is really very interesting and effective.

    PSD to Wordpress
    wordpress website development

    ReplyDelete
  32. I am looking for some good blog sites for studying. I was searching over search engines and found your blog site. Well i like your high quality blog site design plus your posting abilities. Keep doing it.
    best wordpress development company in india
    best iphone-ios-apps-development company in india
    mobile app development company in bangalore

    ReplyDelete
  33. Excellent and helpful post… I am so glad to left comment on this. This has been a so interesting ..I appreciate your effort..
    best wordpress development company in india
    best mobile app development companies in bangalore
    iphone-ios-apps-development companies in bangalore

    ReplyDelete
  34. Looking for WordPress Developer for Hire ? Visit Us at webgensis a Custom WordPress Development Company having team of experienced and skilled developers.

    ReplyDelete
  35. Good article write and good Information share this Article. Android app Development company In India

    ReplyDelete
  36. Great Post! you have done great job.Thanks for sharing it with us. Well done and keep posting Mobile App Development.

    ReplyDelete
  37. Wow amazing post. Thanks for sharing it.
    Hire Iphone Developers

    ReplyDelete
  38. Nice blog. Thanks for sharing such great information.Develop xamarin application Hire xamarin developer , Hire xamarin developer India

    ReplyDelete
  39. Its really good article.I got new information.Tyhank you for posting this articleiOS Training In Chennai | iOS Training Institute In Chennai

    ReplyDelete
  40. Great information on documents directory file path - iPhone, iPad, iOS development. I have read this post and find it very useful. Thanks for sharing this information with us!

    ReplyDelete
  41. Your website is very good and nice information was provided in your site, thanks for sharing.
    iOS Application Development Training in Ameerpet, Hyderabad

    ReplyDelete
  42. Interesting blog, helped to clarify many things, definitely this will be a useful article. Good work, excepting these kinds of more useful blogs and articles.
    Mobile app development Company

    ReplyDelete
  43. This comment has been removed by the author.

    ReplyDelete
  44. Wonderful blog. Thanks for sharing informative Post. Its very useful to me.
    iOS Application Development Training in Ameerpet, Hyderabad

    ReplyDelete