iOS Learning (OC language) Knowledge Point finishing
I. Introduction of iOS sandbox mechanism
1) Concept: Each iOS app has its own app sandbox, the application sandbox is the file system directory, and other apps put in file system isolation, iOS system does not allow access
Application sandbox for other apps, but already open access in iOS8 (extension)
2) extension is a new open-iOS8 mechanism for several fixed system regions, which can compensate to some extent the limitations of iOS sandbox mechanism for communication between applications.
3) The application sandbox typically includes the following file directories:
1. Application Package: Contains all resource files and executable files
2. Documents: Saves data that needs to be persisted when the app runs, and itunes automatically backs up the directory
3. tmp: Save the temporary data required by the application to run, and then delete the corresponding files from the directory after use, the system may automatically clean up when the application is not running.
Files in that directory,itunes will not sync the directory, and the files in that directory will be lost when the iphone restarts.
4. Libaray: Store The program's default settings and other status information, itunes will automatically back up the directory.
5, Libaray/caches: Store cache files, itunes does not back up this directory, the files in this directory will not be deleted in the application, general storage volume is relatively large,
Not a very important resource .
6, Libaray/preferences: Save all the app's preferences, iOS settings (settings) app will find the app's settings information in this directory,
itunes will automatically back up the directory.
4) Get the app's root directory for example:
1 NSString *sandbox=nshomedirectory ();
5) Get the documents directory for your application for example:
1 // 2//3 nsarray *arry= 4 NSLog (@ " %@ ", [Arry lastobject]);
6) Get the app's Libaray directory for example:
1 nsarray *arry2= nssearchpathfordirectoriesindomains (nslibrarydirectory, Nsuserdomainmask, YES); 2 NSLog (@ "%@", [Arry2 lastobject]);
7) Get the app's caches directory for example:
1 nsarray *arry3= nssearchpathfordirectoriesindomains (nscachesdirectory, 2 Nsuserdomainmask, YES); 3 NSLog (@ "%@", [Arry3 lastobject]);
8) Get the preferences directory of the application, can not directly obtain only self-stitching for example:
1 nsarray *arry4= nssearchpathfordirectoriesindomains (nslibrarydirectory, Nsuserdomainmask, YES); 2 nsstring *path=[Arry4 lastobject]; 3 path=[path stringbyappendingpathcomponent:@ "Preferences"]; 4 NSLog (@ "%@", Path);
9) Get the application's TMP directory for example:
1 nsstring *tmp=nstemporarydirectory (); 2 NSLog (@ "%@", TMP);
10) Write the file to the specified application directory for example :
1 nsarray *arry4= nssearchpathfordirectoriesindomains (nslibrarydirectory, Nsuserdomainmask, YES); 2 nsstring *path=3 path=[path stringbyappendingpathcomponent:@ "Preferences /test.txt"]; 4 nsstring *str=@ "abcdefg"; 5 [str writetofile:path atomically:yes encoding:nsutf8stringencoding Error:nil];
iOS Stage Learning 25th Day Notes (Introduction to iOS sandbox mechanism)