iOS sandbox mechanism

Source: Internet
Author: User

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

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.