an iOS sandbox mechanism
for security purposes, applications can only write their own data and preferences to a few specific locations. When an application is installed on a device, a home directory is created for it, which is the sandbox for the application. So the files are to be saved in this, examples like, icons, sounds, images, attribute lists, text files, etc. (for security reasons, the IOS places each app (including it preferences and data) in a sandbox at install time. A sandbox is a set of fine-grained controls that limit the app's access to files, preferences, network resources, hardware , and so on. As part of the sandboxing process, the system installs each app in its own sandbox directory, which acts as the home for T He app and its data.)
1. Each application has its own storage space2, the application can not turn over their walls to access the contents of other storage space3, the application requests the data to pass the permission detection, if does not meet the condition, will not be released. Sandbox is a security system in which all the operations of an application are performed through this system, with the core of which is the sandbox's permission restrictions on the various actions the application performs.
Sandbox in the second simulator
Here's a look at where the emulator's sandbox folder is on your Mac computer. The sandbox files are in a hidden folder under the personal User name folder, the Chinese is called the Resource library, actually is the library. To view the method:
Method 1 You can set the display hidden file and then open it directly under finder. Here's how to set up viewing hidden files: Open terminal, enter command
command to display Mac hidden files: Defaults write Com.apple.finder appleshowallfiles-bool true to hide mac hidden files command: Defaults write Com.apple.finder Appleshowallfiles-bool false After you click Enter to exit the terminal, restart the finder.
Restart Finder: Mouse click the Apple icon in the upper-left corner of the window and force exit-->finder->
Now you can see the repository folder.
Locate the/application support/iphone simulator/folder after opening the repository. This is the sandbox directory of the simulator's various programs.
Method 2 This method is more convenient, on the Finder point-to go to the folder, enter the/users/username/library/application support/iphone simulator/to go. Username here to write your user name. or ~/library/application Support/iphone simulator/(~ Indicates the current user directory)
Three directory structure
by default, each sandbox contains 3 folders: Documents, Library, and TMP. Because of the sandbox mechanism, applications can only read and write to documents in these directories: Apple recommends storing the file data that is created in the program or browsed in the program in that directory, which is included in itunes Backup and restore.
Library: The default settings or other status information of the stored program;library/caches: Store cached files, itunes does not back up this directory, files in this directory will not be deleted in the app exittmp: Provides a place to create temporary files on the fly. itunes backs up all documents and library files while syncing with the iphone. When the iphone restarts, all of the TMP files are discarded.
The three directories mentioned above: Documents, Library, TMP, Xxx.app
Is the structure of a complete home directory:
The next section describes in detail the role of each directory in the sandbox and the code used to access it.
Reference:https://developer.apple.com/library/ios/DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ Theiosenvironment/theiosenvironment.html