iOS Learning notes-data persistence

Source: Internet
Author: User

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

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.