The phone sandbox model has four folders: Documents,tmp,app,library
1.
Documents you should write all the application data files to this directory. This directory is used to store user data or other information that should be backed up regularly.
2,
Appname.app This is the application's package directory, which contains the application itself. Because the application must be signed, you cannot modify the contents of this directory at run time, which may cause the application to fail to start.
3.
Library(including
Caches and Preferences)
Preferences: Contains the application's preferences file. Instead of creating a preference file directly, you should use the Nsuserdefaults class to get and set your application's preferences.
Caches: Used to hold application-specific support files to save the information that is needed during the application startup process.
4.
tmp This directory is used to store temporary files and to save information that is not needed during the application startup process.
ways to get these directory paths:
1, get the home directory path function:
NSString *homedir = nshomedirectory ();
2, getDocuments directory pathMethod of:
Nsarray *paths =Nssearchpathfordirectoriesindomains(nsdocumentdirectory,Nsuserdomainmask, YES);
NSString *docdir =[Paths objectatindex:0];
3, getCaches directory pathMethod of:
Nsarray *paths = Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES);
NSString *cachesdir = [Paths objectatindex:0];
4, gettmp directory pathMethod of:
NSString *tmpdir = Nstemporarydirectory ();
5, getresource file path in application packageMethod of:
For example, get a picture resource (apple.png) path in the package by:
NSString *imagepath = [[nsbundle mainbundle] pathforresource: @ "Apple" ofType: @ " PNG "];
UIImage *appleimage = [[UIImage alloc] initwithcontentsoffile: ImagePath];
the Mainbundle class method in the code is used to return an object that represents the application package.
Ways to get documents, TMP, apps, library paths