About the iOS File System
The iOS record framework is designed for applications running all alone. To keep the framework straightforward, clients of iOS gadgets don’t have direct access to the document framework and applications are relied upon to follow this show.
iOS Standard Directories: Where Files Reside
For security purposes, an iOS application’s collaborations with the document framework are constrained to the indexes inside the application’s sandbox catalog. During establishment of another application, the installer makes various compartment indexes for the application inside the sandbox catalog. Every holder registry has a particular job.
The group compartment catalog holds the application’s pack, while the information holder index holds information for both the application and the client.
The information compartment registry is additionally partitioned into various subdirectories that the application can use to sort and compose its information. The application may likewise demand access to extra holder registries—for instance, the iCloud compartment—at runtime.
These holder indexes comprise the application’s essential perspective on the document system. Figure 1-1 shows a portrayal of the sandbox registry for an application.
An iOS application working inside its own sandbox catalog
An application is commonly restricted from getting to or making documents outside its holder catalogs. One special case to this standard is the point at which an application utilizes open framework interfaces to get to things, for example, the client’s contacts or music.
In those cases, the framework structures use assistant applications to deal with any record related activities expected to peruse from or change the proper information stores.
This is the app’s bundle. This registry contains the application and the entirety of its assets.
You can’t keep in touch with this index. To forestall altering, the group registry is marked at establishment time. Keeping in touch with this index changes the mark and forestalls your application from propelling. You can, in any case, gain read-just access to any assets put away in the applications pack. For more data, see the Resource Programming Guide
The substance of this registry are not upheld up by iTunes or iCloud. In any case, iTunes performs an underlying sync of any applications bought from the App Store.
Utilize this index to store client created content. The substance of this registry can be made accessible to the client through record sharing; hence, this catalog should just contain documents that you may wish to open to the client.
The substance of this index are supported up by iTunes and iCloud.
Utilize this index to get to records that your application was approached to open by outside elements. In particular, the Mail program places email connections related with your application in this index. Archive communication controllers may likewise put documents in it.
Your application can peruse and erase records in this index yet can’t make new documents or write to existing records. In the event that the client attempts to alter a document in this registry, your application should quietly move it out of the index before rolling out any improvements.
The substance of this index are sponsored up by iTunes and iCloud.
This is the top-level index for any documents that are not client information records. You ordinarily put documents in one of a few standard subdirectories. iOS applications generally use the Application Support and Caches subdirectories; be that as it may, you can make custom subdirectories.
Use the Library subdirectories for any records you don’t need presented to the client. Your application ought not utilize these registries for client information records.
The substance of the Library directory (except for the Caches subdirectory) are supported up by iTunes and iCloud.
For extra data about the Library registry and its generally utilized subdirectories, see The Library Directory Stores App-Specific Files.
Utilize this index to compose impermanent records that don’t have to persevere between dispatches of your application. Your application should expel documents from this catalog when they are not, at this point required; be that as it may, the framework may cleanse this registry when your application isn’t running.
The substance of this registry are not supported up by iTunes or iCloud.
An iOS application may make extra registries in the Documents, Library, and tmp directories. You may improve arrange the documents in those areas.
For data about how to get references to the previous catalogs from your iOS application, see Locating Items in the Standard Directories. For tips on where to put documents, see Where You Should Put Your App’s Files.
Where You Should Put Your App’s Files
To forestall the matching up and reinforcement forms on iOS gadgets from taking quite a while, be particular about where you place records. Applications that store huge grinds can hinder the way toward sponsorship up to iTunes or iCloud. These applications can likewise devour a lot of a client’s accessible stockpiling, which may urge the client to erase the application or handicap reinforcement of that application’s information to iCloud. In light of this, you should store application information as indicated by the accompanying rules:
Put client information in Documents/. Client information for the most part incorporates any records you should open to the client—anything you may need the client to make, import, erase or alter. For a drawing application, client information incorporates any realistic documents the client may make. For a content tool, it incorporates the content documents. Video and sound applications may even incorporate records that the client has downloaded to watch or tune in to later.
Put application made help records in the Library/Application support/ directory. By and large, this index incorporates records that the application uses to run yet that ought to stay avoided the client. This catalog can likewise incorporate information records, setup documents, layouts and altered adaptations of assets stacked from the application pack.
Recollect that records in Documents/ and Application Support/ are sponsored up as a matter of course. You can reject records from the reinforcement by calling -[NSURL setResourceValue:forKey:error:] using the NSURLIsExcludedFromBackupKey key. Any document that can be re-made or downloaded must be rejected from the reinforcement. This is especially significant for enormous media documents. On the off chance that your application downloads video or sound documents, ensure they are excluded from the reinforcement.
Put impermanent information in the tmp/ directory. Brief information involves any information that you don’t have to endure for an all-inclusive timeframe. Make sure to erase those documents when you are finished with them so they don’t keep on expending space on the client’s gadget. The framework will occasionally cleanse these documents when your application isn’t running; subsequently, you can’t depend on these records continuing after your application ends.
Put information reserve records in the Library/Caches/ directory. Store information can be utilized for any information that requirements to endure longer than impermanent information, yet not up to a help record. As a rule, the application doesn’t require store information to work appropriately, however it can utilize reserve information to improve execution. Instances of store information incorporate (yet are not restricted to) database reserve documents and transient, downloadable substance. Note that the framework may erase the Caches/ directory to let loose circle space, so your application must have the option to re-make or download these records varying.