Learn ios--Path Detailed understanding

Source: Internet
Author: User

The use of the create groups for any added folders means that all resources are placed under the resource bundle path, with no hierarchical concept
Using the Create folder references for any added folders is represented by placing them in the installation package in the same way as the original folders.
There are several such folders in the installation package: (these files are located under the home path)
(1) Documents: This folder is used to write program data files to this directory for storing user data and data that needs to be backed up.
(2) Library:include Caches and Preferences.
Preferences: For placing user preferences data, you cannot directly create a preferred settings file, you should use the Nsuserdefaults class to get and set application preferences
Caches: For storing application-specific support files, save the information required for the application to start the process again.
(3) TMP: temporary folder, the next time you start the folder will be deleted.




Methods to get the directory:
(1) How to get home directory:
NSString *homedir = Nshomedirectory ();


(2) How to obtain the Documents directory path:
Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);
NSString *docdir = [Paths objectatindex:0];
(3) How to get the caches directory path:
Nsarray *paths = Nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES);
NSString *cachesdir = [Paths objectatindex:0];
(4) method to get the TMP directory path:
NSString *tmpdir = Nstemporarydirectory ();
(5) How to obtain the path of the resource file in the application package (get Apple.png);
NSString *imagepath = [[NSBundle mainbundle] pathforresource:@ "apple" oftype:@ "PNG"];

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.