First, sand box
The sandbox directory is a data security policy, and many systems use sandbox design.
The principle of sandboxed directory design is that you can only allow your own applications to access the directory and not allow other apps to access it.
1. Documents directory: This directory is used to store very large files or very frequently updated data, to be able to do itunes or icloud backup, get directory location code is as follows:
1 nsstring * Patharr = [Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask, YES) Lastobject]; 2 nsstring * strpath = [Patharr stringbyappendingpathcomponent:@ "sjz.plist"];
2. Library directory: In the Library directory there are preferences and caches directories, the former for storing the application settings data, or similar to documents, you can store the application data, to store the cache file.
3. Tem directory: This is a temporary file directory where users can access it and it is not possible to back up your line of itunes or icloud. Methods to get the directory:
1 nsstring * Tempath = Nstemporarydirectory ();
Second, data persistence
The persistence approach is the way data is stored, and iOS supports local storage and cloud storage.
1. Attribute list: The collection object can read and write the property list.
2. Object archive: The object state can be saved to the archive file.
3, SQLite database: SQLite database is an open-source embedded relational database.
4, Core Data: It is an object-relational mapping technique, which is also stored by SQLite in nature.
Property lists and object archives are generally used to store a small amount of data, the property list file access is easier than the object archive access, the collection object has a corresponding method to read and write properties Leibiao file, and the object Archive book with the help of NSData implementation, use more trouble.
The SQLite database and core data are typically used in situations where there is a large amount of information with several simple table relationships.
iOS Learning notes-data persistence