Get the application sandbox sandbox method:
by printing NSString *path = Nshomedirectory () in the iOS program Viewdidload; You can then go to the printed path in the Finder to see the sandbox sandbox for that program.
Example:/users/wujia121/library/developer/coresimulator/devices/3fdee527-d4db-492f-9490-1d04af9559a8/data/ containers/data/application/82a190d8-c6f2-444f-90a5-17b051cc0021
(The sandbox is saved in the Mac user folder, and the SDK is saved in the Xcode content)
The iphone sandbox model has four folders:
The app package is documents,tmp,library, respectively. Manually saved files in the documents file, Nsuserdefaults saved files in the Tmp folder.
1. Documents directory: You should write all the de 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 directory: 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 directory: There are two sub-directories under this directory: Caches and Preferences
Preferences directory: 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 directory: Used to hold application-specific support files, saving the information that is needed during application startup.
4. tmp directory: This directory is used to store temporary files, saving information that is not needed during the application restart.
Ways to get these directory paths:
1, get the Home directory path function:
NSString *homedir = Nshomedirectory ();
2. Method for obtaining the Documents directory path:
Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
NSString *docdir = [Paths objectatindex:0];
3, get the Caches directory path method:
Nsarray *paths = Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES);
NSString *cachesdir = [Paths objectatindex:0];
4. Method to get the TMP directory path:
NSString *tmpdir = Nstemporarydirectory ();
5, gets the method of the resource file path in the application package:
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.
Sandbox path:
iOS Application sandbox sandbox knowledge (original)