One, each iOS Application SDK is limited in the sandbox, the sandbox is equivalent to a folder with only the owner visible permissions, Apple has the following restrictions on the sandbox.
(1), the application can operate in its own sandbox, but cannot access any other application's sandbox.
(2), data cannot be shared between applications, files in the sandbox cannot be copied to other application folders, and files in other application folders cannot be copied into the sandbox.
(3), Apple prohibits any read and write files outside the sandbox, and prohibits the application from writing content to a folder other than the sandbox.
(4), there are three folders in the root directory of the sandbox:
Documents: The application's data files should generally be stored in this folder for storing user data or other information that should be backed up regularly.
Library: There are two folders, caches store application to start the required information (cache files, etc.), preferences contains the application preferences file, but do not modify the preferences here.
Temp: Holds temporary files, that is, the app starts the unwanted files again.
Second, get the sandbox path
(1), there are several ways to get the sandbox root directory:
A. Get with Nshomedirectory
1 nsstring *path = nshomedirectory (); 2 NSLog (@ "path =%@", Path);
b, using the user name to obtain
1 nsstring *username = Nsusername (); // gets the name of the user who created the application 2 nsstring *rootpath = nshomedirectoryforuser (userName); 3 NSLog (@ "rootpath =%@", RootPath);
C. Get Documents Path
1 nsstring *documentpath = [Nssearchpathfordirectoriesindomains (nsdocumentdirectory, NSUserDomainMask, YES) Objectatindex:0]; 2 nsstring *filepath = [documentpath stringbyappendingstring:@ "data.plist"]; // add files to documents 3 NSLog (@ "filePath =%@", FilePath);
D. Get the temp path
1 nsstring *temppath = Nstemporarydirectory (); // Get temp directory, if write data inside, when program exits will empty 2 NSLog (@ "temppath =%@", TempPath);
E. Get caches path
1 nsarray *paths = nssearchpathfordirectoriesindomains (nscachesdirectory, Nsuserdomainmask, YES); 2 nsstring *cachespath = [paths Objectatindex:0]; 3 NSLog (@ "cachespath =%@", Cachespath);
iOS sandbox (sandbox) mechanism and get sandbox path