Sandbox mechanism of iOS system

Source: Internet
Author: User

For security reasons, iOS restricts each application to a specific file. Other apps do not have the permission to access this folder. This is the sandbox of the app.

Common file directories for iOS apps:

 

<Home>/AppName. app package directory

 

<Home>/Documents/important data files and user data files of applications are stored in this directory. When iTunes backs up and recovers, this directory is copied.

 

<Home>/Library/Preferences: stores preference files of the app and files generated using the NSUserDefaults class.

 

<Home>/Library/Caches is used to store support files and cache files generated during app usage. It is recommended that you store log files in this directory. ITunes will not back up this directory file.

 

<Home>/tmp/is used to store temporary files and will not be backed up. The system may clear this directory.

 

Note: Generally, the most important and not huge files are stored in the Documents directory. Otherwise, it takes a long time for iTunes backup.

 

 

Use System APIs to access folders in sandbox


NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES );


NSString * documentsDirectory = [paths objectAtIndex: 0];


Common search path constant: www.2cto.com

NSDocumentDirectory <Application_Home>/Documents

NSCachesDirectory <Application_Home>/Library/Caches

Nsapplicationsuppdirectory directory <Application_Home>/Library/Application Support

 

 

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.