Today, I finally got the directory under iOS to figure it out. That's the way it turned out.
First, the sandbox mechanism in iOS
· iOS applications can only read files to the file system that they create, a separate, closed, and secure space called a sandbox. It typically holds package files (executables), pictures, audio, video, plist files, SQLite databases, and other files.
· each application has its own separate storage space (sandbox)
· Generally, applications are not accessible to each other
Location of the simulator sandbox
/user/username/library/application Support/iphone Simulator
When we created the application, there were three files in each sandbox, namely document, library, and temp.
• Document: Always need persistent data in this directory, you can add sub-folders, itunes backup and restore, will include this directory.
• Library: Set default settings and other status information for the program
• Temp: Creates a directory of temporary files that are automatically erased when the iOS device restarts
Two, iphone sandbox 4 files
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 sub-directories under this directory: Caches and Preferences
Preferences directory: 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 hold application-specific support files, saving the information that is needed during application startup.
4. tmp directory: This directory is used to store temporary files, saving information that is not needed during the application restart.
Okay, on the code:
- (void) viewdidload{[Super Viewdidload]; //Do any additional setup after loading the view.Self.title=@"Rootviewcontroller"; //Get root directoryNsstring*homepath =nshomedirectory (); NSLog (@"Home directory:%@", HomePath); //Get the Documents folder directory, the first parameter is the description get doucments folder directory, the second parameter description is obtained in the current application sandbox, all application sandbox directory composed of data stored in an array structureNsarray*docpath =nssearchpathfordirectoriesindomains (Nsdocumentdirectory,nsuserdomainmask, YES); NSString*documentspath = [DocPath objectatindex:0]; NSLog (@"Documents directory:%@", Documentspath); //get the Cache directoryNsarray*cacpath =nssearchpathfordirectoriesindomains (Nscachesdirectory, Nsuserdomainmask, YES); NSString*cachepath = [Cacpath objectatindex:0]; NSLog (@"Cache directory:%@", CachePath); //Library DirectoryNsarray*libspath =nssearchpathfordirectoriesindomains (Nslibrarydirectory, Nsuserdomainmask, YES); NSString*libpath = [Libspath objectatindex:0]; NSLog (@"Library Catalog:%@", LibPath); //Temp directoryNsstring*temppath =nstemporarydirectory (); NSLog (@"Temp directory:%@", TempPath);}
Print out of:
the- .- - -: About:55.257Directory for iOS [6565: 60b] Home directory:/users/li/library/application support/iphone simulator/7.1/applications/678b1114-663e-4550-a115-1934E4E70DF2 the- .- - -: About:55.257Directory for iOS [6565: 60b] Documents directory:/users/li/library/application support/iphone simulator/7.1/applications/678b1114-663e-4550-a115-1934e4e70df2/Documents the- .- - -: About:55.258Directory for iOS [6565: 60b] Cache directory:/users/li/library/application support/iphone simulator/7.1/applications/678b1114-663e-4550-a115-1934e4e70df2/library/Caches the- .- - -: About:55.259Directory for iOS [6565: 60b] Library directory:/users/li/library/application support/iphone simulator/7.1/applications/678b1114-663e-4550-a115-1934e4e70df2/Library the- .- - -: About:55.259Directory for iOS [6565: 60b] Temp directory:/users/li/library/application support/iphone simulator/7.1/applications/678b1114-663e-4550-a115-1934e4e70df2/tmp/terminatinginchResponse to Springboard's termination.