IOS Sandbox directory Structure

Source: Internet
Author: User

On an iOS system, each app has its own sandbox, and the app can only access files under its corresponding sandbox directory. Of course, in the case of user authorization, the app can also access files under other directories. For example, in the case of user authorization, the app can access albums, Contacts. In development, it often involves the IOS sandbox directory, such as reading and writing files, archiving, and so on.

A: The directory structure of the sandbox

The sandbox directory structure of the app is as follows:


There are three folders in the Sandbox directory: Documents, Library, Temp. Among them, there are two folders under the library, namely Preferences and Caches.

II: Files stored in each directory

1:documents directory: Used to store user data, all application data files should be written to that directory.

2:library directory: (1) Preferences directory: Contains the application's Preferences file (2) Caches directory: Used to store application-specific support files, saving the information needed during the application restart.

3:temp directory: For storing temporary files, save information that is not needed during the application restart.

Three: How to get the sandbox directory

Get the Sandbox directory path through the Nssearchpathfordirectoriesindomains method, the method has three parameters:

1:directory the enum value of the Nssearchpathdirectory type, the name of the directory to search for emoticons.

2:domainmask the enum value of the Nssearchpathdomainmask type, specifying the search scope. Typically, Nsuserdomainmask, which indicates that the search scope is limited to the currently applied sandbox directory.

A 3:expandtilde bool value that indicates whether to expand ~ in the returned path. If yes, expands, no indicates no expansion.

To get the code for the Sandbox directory path:

//Get Sandbox home directory pathNSString *Homedir= nshomedirectory();//Get documents directory pathNSString *Docdir= [Nssearchpathfordirectoriesindomains(nsdocumentdirectory, Nsuserdomainmask,YES)Firstobject];//Get directory path of libraryNSString *Libdir= [Nssearchpathfordirectoriesindomains(nslibrarydirectory, Nsuserdomainmask,YES)Lastobject];//Get caches directory pathNSString *Cachesdir= [Nssearchpathfordirectoriesindomains(nscachesdirectory, Nsuserdomainmask,YES)Firstobject];//Get the TMP directory pathNSString *TmpDir=  nstemporarydirectory();

Example path when the third parameter is yes:

/var/Mobile/Applications/DBAC1849-cf0a-435A-98FB-a7472c73ec42/Library/Caches/letuallclassifystring.plist

example path when the third parameter is no:

~ /library/ Caches / letuallclassifystring . plist

IOS Sandbox directory Structure

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.