Differences between nssearchpathfordirectoriesindomains and nshomedirectory

Source: Internet
Author: User

The iPhone will generate a private directory for each application, which is located:

/Users/sundfsun2009/library/Application Support/iPhone simulator/user/applications,

Then, a numeric string is generated as the directory name. This letter and number string is different from the previous one when the application starts.


Therefore, the documents directory is usually used for persistent data storage, and the documents directory can be stored through:

Nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes.

The Code is as follows:

Nsarray * paths = nssearchpathfordirectoriesindomains (nsdocumentdirectory, nsuserdomainmask, yes );

Nsstring * documentsdirectory = [paths objectatindex: 0];

Nslog (@ "Path: % @", PATH );

The output is as follows:

Path:/users/Apple/library/Application Support/iPhone simulator/4.3/applications/550af26d-174b-42e6-881b-b7499faa32b7/Documents

The nshomedirectory () can also be used to obtain the program directory. The Code is as follows:

Nsstring * destpath = nshomedirectory ();

Nslog (@ "Path: % @", destpath );

The output is as follows:

Path:

/Users/Apple/library/Application Support/iPhone simulator/4.3/applications/550af26d-174b-42e6-881b-b7499faa32b7

We can see the differences between the two methods.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.