IOS sandbox Mechanism

Source: Internet
Author: User

IOS applications can only read files from the file system created for the modified program. They cannot be accessed elsewhere. This region is called sandbox and all non-code files must be stored here, example: image, icon, sound, image, attribute list, text file, etc. each application has its own storage space. applications cannot access contents in other buckets through their own walls. 3. all data requested by the application must pass permission detection. If the data does not meet the conditions, it will not be released.
IOS sandbox structure application package: (Bundle) contains all resource files and executable files
Documents: stores the persistent data generated during application running. This directory is backed up when the iTunes synchronization device is used. For example, a game application can save a game archive in this directory (game data)
Library/Caches: stores the persistent data generated during application running. This directory is not backed up when the iTunes device is synchronized. Non-important data that is generally stored in a large volume and does not need to be backed up (Weibo images)
Library/Preference: stores all Preference settings of an application. The iOS setting application searches for the application settings in this directory. This directory is backed up when the iTunes synchronization device is running.

(That is, personalized settings, user login name and password)


Tmp: Save the temporary data required for running the application. After using the temporary data, delete the corresponding files from this directory. When the application is not running, the system may also clear files in the directory. This directory is not backed up when iTunes synchronizes devices (unimportant files)
Obtain the sandbox directory:
// Obtain the installation directory NSString * home = NSHomeDirectory (); NSLog (@ "program directory % @", home ); // obtain the document directory // NSUserDomainMask. Starting from the user folder, find "YES", which indicates the Tilde "~" in the expanded path. NSArray * documet = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES); NSString * doc = et [0]; // obtain the document directory NSString * path = [home stringByAppendingString: @ "Documents"]; // obtain the cache directory NSArray * cache = NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDomainMask, YES); NSLog (@ "cache =%@", cache [0]); NSLog (@ "% @", path); // obtain the temp directory NSString * temp = NSTemporaryDirectory ();

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.