iOS Stage Learning 25th Day Notes (Introduction to iOS sandbox mechanism)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.