Detailed explanation of paths in ios

Source: Internet
Author: User

By using the create groups for any added folders method, all resources are placed under the Resource Package path, and there is no hierarchical concept.
The expression like create folder references for any added folders is to put them in the installation package as the original folder.
There are several folders in the installation package: (these files are located in the home path)
(1) Documents: this folder is used to write program data files to this directory to store user data and data to be backed up.
(2) Library: include Caches and Preferences.
Preferences: used to store user Preferences. You cannot directly create Preferences. You should use the NSUserDefaults class to obtain and set application Preferences.
Caches: used to store application-specific support files and save the information required for the application restart process.
(3) tmp: Temporary Folder. The folder will be deleted the next time it is started.




How to get the directory:
(1) method for obtaining home directories:
NSString * homeDir = NSHomeDirectory ();


(2) how to obtain the paths of the Documents directory:
NSArray * paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES );
NSString * docDir = [paths objectAtIndex: 0];
(3) how to obtain the Caches directory path:
NSArray * paths = NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDomainMask, YES );
NSString * cachesDir = [paths objectAtIndex: 0];
(4) method for obtaining the tmp directory path:
NSString * tmpDir = NSTemporaryDirectory ();
(5th vertex of the resource file in the application package (apple.png );
NSString * imagePath = [[NSBundle mainBundle] pathForResource: @ "apple" ofType: @ "png"];

Related Article

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.