Compare four kinds of data storage in iOS

Source: Internet
Author: User
Tags sqlite

What is the method you use to persist data? This is an issue that will be mentioned in almost every conversation or discussion about iOS technology, and the enthusiasm for this issue continues to soar. This article mainly from the concept of "data storage" This problem, and combined with their characteristics and the application of the scene to provide you with a choice of ideas, does not elaborate on a certain way of technical details.

When it comes to data storage, the first thing to distinguish between two concepts, data structure and storage mode. The so-called data structure is the form of the existence. In addition to the basic nsdictionary, Nsarray, and Nsset objects, there are more complex structures such as relational models, object graphs, and attribute lists. The storage mode is simply divided into two types: memory and Flash. Memory storage is temporary, runtime efficient, but efficient, while flash memory is a persistent storage, but generate I/O consumption, the efficiency is relatively low. The operation of moving memory data into Flash is called an archive.

The combination of the two is a complete data storage solution, our most talk about: SQLite, CoreData, nsuserdefaults are data storage solutions. Of course, in addition to the program provided by these frameworks, we can also customize the customized requirements. These storage scenarios focus on different, supporting the form and manner are also different, in various use of the scene performance is also the pros and cons. But same, no matter what the plan can be used to explain the figure.

Figure 1, schematic diagram of the storage scenario

The following four types of storage are described in detail:

Nsuserdefaults, for storing configuration information

SQLite, used to store more data for query needs

CoreData, for planning objects in applications

Personalized caching scheme with basic object type customization

Storing configuration information with Nsuserdefaults

Nsuserdefaults is designed to store configuration information for devices and applications, and it returns the default, and most commonly used, instance objects through a factory method. This object stores the configuration information of the user in the system, the developer can modify the existing information through this instance object, or create new configuration items according to their own requirements.

Fig. 2, the contents of [Nsuserdefaults Standarduserdefaults] in the author's mobile phone

Related Article

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.