1, simulator sandbox directory files are in the personal User name folder in a hidden folder, Chinese is called a resource library, his directory is actually the library.
Because the application is in the sandbox (sandbox), the file read and write permissions are restricted, only a few directories to read and write files:
Documents: User data in the app can be placed here, itunes Backup and restore will include this directory
tmp: storing temporary files, itunes does not back up and restore this directory, files in this directory may be deleted after the app exits
Library/caches: Store cached files, itunes does not back up this directory, files in this directory will not be deleted in the app exit
itunes backs up all documents and library files while syncing with the iphone. When the iphone restarts, all of the TMP files are discarded.
View method: Method 1, you can set the display hidden files, and then open directly under the Finder. Here's how to set up viewing hidden files: Open terminal, enter name (1) command to display Mac hidden files: Defaults write Com.apple.finder Appleshowallfiles-bool true (2) command to hide Mac hidden files: Defaults write Com.apple.finder Appleshowallfiles-bool false (3) After you click Enter to exit the terminal, restart the finder. Restart Finder: Click the Apple icon in the upper-left corner of the window and force exit-->finder--> Now you can see the repository folder. Locate the/application Support/iphone simulator/folder after opening the repository. This is the sandbox directory of the simulator's various programs. Method 2, this method is more convenient, on the Finder point-to go to the folder, enter/users/username/library/application Support/iphone simulator/to go. Username Write the user name here.
Code View directory:
NSString *path = Nshomedirectory ();//Home Directory NSLog (@"nshomedirectory:%@ ",path); NSString *username = Nsusername (); // same as above nsstring *rootpath = Nshomedirectoryforuser (userName); NSLog (@ "nshomedirectoryforuser:%@ ",rootpath); Nsarray *paths = Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES); NSString *documentsdirectory=[paths objectatindex:0]; documents directory NSLog (@ " nsdocumentdirectory:%@
The results are as follows:
2013-09-: 27.210 ios what [8383:c07] nshomedirectory:/users/wmm/library/ Application Support/iphone simulator/6.1/applications/d803dbd2-9cb2-4d18-9152- 6e9398eff5db 2013-09-: 27.210 ios what [8383:c07] Nshomedirectoryforuser:/users/wmm/library /application support/iphone simulator/6.1/applications/d803dbd2-9cb2-4d18-9152- 6e9398eff5db 2013-09-: 27.211 ios what [8383:c07] nsdocumentdirectory:/users/wmm/ Library/application support/iphone simulator/6.1/applications/d803dbd2-9cb2-4d18-9152- 6e9398eff5db/documents The custom class returns each directory path:
#import <Foundation/Foundation.h>@interface icsandboxhelper:nsobject+ (NSString *) HomePath; // Program home directory, Visible subdirectories (3):D ocuments, Library, tmp+ (NSString * ) AppPath; // program directory, can not save anything + (NSString *) DocPath; // document directory, which requires itunes to sync the backup data stored here, can hold user Data + (NSString *) Libprefpath; // config directory, config file stored here + (NSString *) Libcachepath; // cache directory, the system will never delete files here, itunes will delete + (NSString *) Tmppath; // temporary cache directory, after the app exits, the system may delete the content here + (BOOL) Haslive: ( NSString *) path; // to determine if the directory exists, not exist, create a
#import"ICSandboxHelper.h"@implementationicsandboxhelper+ (NSString *) homepath{ReturnNshomedirectory ();} + (NSString *) apppath{Nsarray * paths =Nssearchpathfordirectoriesindomains (Nsapplicationdirectory, Nsuserdomainmask, YES);return [Paths Objectatindex:0];} + (NSString *) docpath{Nsarray * paths =Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES);return [Paths Objectatindex:0];} + (NSString *) libprefpath{Nsarray * paths =Nssearchpathfordirectoriesindomains (Nslibrarydirectory, Nsuserdomainmask, YES);return [[Paths Objectatindex:0] Stringbyappendingformat:@"/preference"];} + (NSString *) libcachepath{Nsarray * paths =Nssearchpathfordirectoriesindomains (Nslibrarydirectory, Nsuserdomainmask, YES);return [[Paths Objectatindex:0] Stringbyappendingformat:@ "/caches" ];} + (nsstring *) Tmppath{return [Nshomedirectory () Stringbyappendingformat:@ "/tmp ") path{if (NO == [[Nsfilemanager Defaultmanager] Fileexistsatpath:path] {return [[Nsfilemanager Defaultmanager] Createdirectoryatpath:path withintermediatedirectories:yes attributes:nil Error: NULL]; } return NO;
viewing and using the iOS sandbox path