1, iOS sandbox mechanism in iOS systems, the system creates a resource directory for each app, which is called a sandbox. It contains pictures, properties files, plist,bundle,nib files, and so on. Its characteristics are as follows:1, each application has its own storage space--Sandbox. 2, each app only has access to its own sandbox and cannot access other sandboxes3, file operations for each application must be within the sandbox, such as database storage, file storage, etc.2, sandbox directory structure the user data in the Documents application can be placed here, itunes Backup and restore will include this directory---Caches Storage application starts again the required information Library---------| ---Preferences contains the application preferences file, but do not modify the preferences in the TMP store temporary files, itunes does not back up and restore this directory, the files in this directory may be deleted after the app exits3, sandbox directory fetching+ (NSString *) HomePath;//Program Home Directory, Visible subdirectories (3):D ocuments, Library, TMP+ (NSString *) AppPath;//program directory, can't save anything+ (NSString *) DocPath;//The document directory, which requires itunes to synchronize the backup data stored here, can store user data+ (NSString *) Libprefpath;//configuration directory, configuration file stored here+ (NSString *) Libcachepath;//cache directory, the system will never delete files here, itunes will delete+ (NSString *) Tmppath;//temporary cache directory, after the app exits, the system may delete the content here+ (BOOL) haslive: (NSString *) path;//determines whether the directory exists, does not exist, and creates+ (NSString *) homepath{returnnshomedirectory ();}+ (NSString *) apppath{Nsarray* Paths =nssearchpathfordirectoriesindomains (Nsapplicationdirectory, Nsuserdomainmask, YES); return[Paths Objectatindex:0];}+ (NSString *) docpath{Nsarray* Paths =nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES); return[Paths Objectatindex:0];}+ (NSString *) libprefpath{Nsarray* Paths =nssearchpathfordirectoriesindomains (Nslibrarydirectory, Nsuserdomainmask, YES); return[[Paths Objectatindex:0] Stringbyappendingformat:@"/preference"];}+ (NSString *) libcachepath{Nsarray* Paths =nssearchpathfordirectoriesindomains (Nslibrarydirectory, Nsuserdomainmask, YES); return[[Paths Objectatindex:0] Stringbyappendingformat:@"/caches"];}+ (NSString *) tmppath{return[Nshomedirectory () Stringbyappendingformat:@"/ tmp"];}+ (BOOL) haslive: (NSString *) path{if(NO = =[[Nsfilemanager Defaultmanager] Fileexistsatpath:path]) { return[[Nsfilemanager Defaultmanager] Createdirectoryatpath:path Withintermediatedi Rectories:yes Attributes:nil Error:null]; } returnNO;}
iOS sandbox mechanism