Original blog, reproduced please indicate the source
Blog.csdn.net/hello_hwc
Objective:
The iOS sandbox mechanism restricts access to the app, thereby protecting the user's data information.
One view sandbox structure
And some Baidu blog to show the way to hide stable files, this article also provides two ways, simple rough.
Mode one use tool simpholders (recommended)
Download link
http://simpholders.com/
Effect
Mode two using code directly
Log out of the documents/path with the following code
NSURL * url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
Like the result of my log.
/Users/huangwenchen/Library/Developer/CoreSimulator/Devices/158D1CE6-0444-454B-B248-798726D6BC40/data/Containers/Data/Application/77B749FB-7B2F-4AE5-BE24-039BF3760F67/Documents/
Then, double-click finder-> to go to folder---Copy the above path
Two Sandbox catalogue Introduction
The Directory of the Sandbox
It is not difficult to see, mainly including three parts, Bundle,data and icloud.
And data also includes three parts, Documents,library,temp.
Then, we describe each part of the sandbox's role.
| name |
function |
| Appname.app |
The bundle of apps includes all the resources of the app and app (icon at the time of installation, pictures saved in the app package), read-only. Will not be backed up by itunes and will only be synced once from the App store when it was originally started. |
| documents/ |
Store user-generated content. The files in this directory can be exposed to the user through file sharing, that is, this directory can only store what you want to expose to the user. itunes backup |
| library/ |
A top-level directory of non-user files, using this directory to store files that you do not want to expose to users. This directory has many subdirectories, which are described in detail below. |
| tmp/ |
Temporary file, the app should delete the file when it doesn't need to be used. Store data that will not be used in two run apps. Will not be backed up by itunes. |
Sub-directory of the Library
| name |
function |
| Caches |
Write files that the app can easily recreate, the app to manage the directory, and add or delete files when appropriate. For example, a Web page's cache file: |
| Preferences |
User preference information. For example nsuserdefaults stored here for a long time |
Three-proof
Here, open a nsurlsession demo sandbox I wrote earlier.
By the way, we open the sandbox and see what's inside.
First look at the bundle directory
My simulator has three software that corresponds to three bundles here.
Take a look at the data directory, exactly three directories corresponding to the three directories above
,
As you can see, look at the library's Word directory, which stores the Cache,cookie, and preferences information.
BTY: How to access these directories in code under the next update. In addition, many students do not know the library directory and document the difference, the biggest difference is in the above table in the red Word.
IOS SDK detailed sandbox (i) illustration + gadget