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 ();