The iphone sandbox model has four folders, what is it, where is the permanent data store, and what is the simple way to get the path to the emulator. Documents,tmp,app,library. (Nshomedirectory ()), manually saved files in the documents file Nsuserdefaults saved files in the TMP folder 1, documents directory: You should write all the de application data files to this directory. This directory is used to store user data or other information that should be backed up regularly. 2. Appname.app directory: This is the application's package directory, which contains the application itself. Because the application must be signed, you cannot modify the contents of this directory at run time, which may cause the application to fail to start. 3. Library directory: There are two subdirectories under this directory: Caches and Preferencespreferences Directories: Contains the application's preferences file. Instead of creating a preference file directly, you should use the Nsuserdefaults class to get and set your application's preferences. Caches directory: Used to store application-specific support files to save the information that is needed during the application restart. 4. tmp directory: This directory is used to store temporary files, saving information that is not needed during the application restart. Methods to get these directory paths: 1, Get home directory path function: NSString *homedir = Nshomedirectory (); 2, method for obtaining the Documents directory path: Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES); NSString *docdir = [Paths objectatindex:0];3, get the Caches directory path method: Nsarray *paths = Nssearchpathfordirectoriesindomains ( Nscachesdirectory, Nsuserdomainmask, YES); NSString *cachesdir = [Paths objectatindex:0];4, method to get the TMP directory path: nsstring *tmpdir = Nstemporarydirectory (); 5, get the method of the resource file path in the application package: For example, get a picture resource in the package (APPLE.PNG) path: NSString *imagepath = [[NSBundle mainbundle] pathforresource:@ "apple" oftype:@ "PNG"]; UIImage *appleimage = [[UIImage alloc] initwithcontentsoffile:imagepath]; the Mainbundle class method in the code is used to return an object that represents the application package.
Go Ways to get directory paths for various files in iOS