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.