iOS apps can only access areas created by the system for the app, not other areas, which is the sandbox (sandbox). We often put some pictures, properties files (plist files) and so forth into this directory for use in development.
1. Get the Sandbox path
A. Getting the emulator sandbox path
If you do not know the application sandbox path you are looking for in development, you can print your sandbox path through the Nshomedirectory () method.
eg
NSLog (@ "sandbox path---->%@", Nshomedirectory ());
After running the visible console output is as follows:
The console output is the app sandbox address you want to find. Using Command+shift+g, copy and paste the path of the console output and enter it into the application's sandbox.
B. Getting a real-machine sandbox path
If you are in development, you need to get the sandbox address of the real machine to see if something is successfully stored as expected.
The steps are:
ba. Connect the real machine to Xcode, run the application, i.e. the project;
bb. Click the window on the Finder and click Window, as shown in
BC. After clicking on the window, a drop-down menu appears, select Device, and enter the
Bd. Action as shown
Be. When you have completed BD, specify a location, such as desktop, click Download, get a package.
BF. Right click to open the contents of the package O.
2. Folder construction and function under sandbox
A total of 3 folders under the sandbox are:Documents, Library,tmp. Functions as follows:
Documents:
1. We often keep the application's data files in this directory. However, these data types are basically non-renewable data ;
2. This folder will be synced by itunes ;
3. The method to obtain the directory is:
Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES); NSString *path = [Paths objectatindex:0]; NSLog (@ "Document path------>%@", path);
Library:
1. Store the program's default settings or other status information ;
2. The folder will be synced by ITunes ;
3. The method to obtain the directory is:
Nsarray *paths = Nssearchpathfordirectoriesindomains (Nslibrarydirectory, Nsuserdomainmask, YES); NSString *path = [Paths objectatindex:0]; NSLog (@ "Library path----->%@", path);
4. This catalogue also has two subdirectories: caches and preferences
Library /caches
1. Mainly cache files (renewable files, such as network request data), the user in the process of using the cache can be saved in this directory.
2. The method to obtain the directory is:
Nsarray *paths = Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES); NSString *path = [Paths objectatindex:0]; NSLog (@ "%@", Path);
Library/preferences
1. Keep Some preference settings in common terms;
tmp:
1. Provide only one place where temporary files are created instantly ;
2. The folder will not be synced by ITunes ;
3. The method to obtain the directory is:
NSString *tmpdir = Nstemporarydirectory ();
IOS sandbox mechanism