IOS-sandbox mechanism and User File Operations

Source: Internet
Author: User

1. iOS sandbox Mechanism

IOS creates a file system structure for each application to store the application files. This area becomes a sandbox, including audio, image, text, and other files.

1. Each application has its own storage space.

2. applications cannot access other program's bucket content

3. the data requested by the application must pass permission detection. If the request does not meet the conditions, the data will not be released.

2. Sandbox path

On the finder, click-> go to the folder and enter/users/username/library/Application Support/iPhone simulator.

Enter your username here.


The program code can directly find the path: nshomedirectory ();


Take an application of mine as an example to manually find the sandbox path


The last four files are common folders in the sandbox.


(1) Here, my application project name is addressbook. Therefore, the first package contains some images, sounds, text files, and code files referenced in the project.

Each time the content in this file is run from the simulator, the source code is reinjected into the package, so it is a temporary buffer file. Generally, we put some unchanged configuration files and resource files into it,

So that each running program can be loaded and the program running cannot be changed.

This package cannot be opened directly by double-clicking. You can only right-click to display the package content.

(2) The document folder is usually used to store files that may be modified by users and can be stored persistently.

For example, if there is a file named "addressbooklist. plist" in this folder, the corresponding path is:

NSArray *pathArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);NSString *path=[[pathArray objectAtIndex:0] stringByAppendingPathComponent:@"addressBookList.plist"];

(3) TMP: provides a place to create temporary files in real time.

(4) Library: the default setting or other State information of the storage program;

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.