iOS application directory structure

iOS applications are designed using the principle of sandboxing, popularize the knowledge: sandboxing is a practice of running applications in a restricted security environment, which is to restrict the code access rights of the application.
There are three specific characteristics:

1. Each application has its own storage space;

 2. The application cannot climb over its own wall to access the content of other storage spaces;

3. The data requested by the application must pass the permission detection. If it does not meet the conditions, it will not be released.
 
On the Finder, click -> Go -> Go to Folder, enter /Users/username/Library/Application Support/iPhone Simulator/ to go. username Write your username here.

This will find the sandbox directory of the app on the emulator on the Mac.

Each application has its own independent three directories: Document, Library, tmp , and these three directories cannot access each other.
Documents:

Apple recommends saving the file data created in the program or browsed in the program in this directory, which will be included in iTunes backup and restore.

The path to Documents can be obtained by the following code:

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


Library:

Store program default settings or other status information;


Library/Caches:

Store cache files, iTunes will not back up this directory, and files in this directory will not be deleted when the application exits;

The path to Library/Caches can be obtained by the following code:

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


tmp:

Provides a place to create temporary files on the fly.
 
iTunes backs up all Documents and Library files when syncing with the iPhone.
When the iPhone restarts, all tmp files are discarded.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326992143&siteId=291194637