The difference between SQLite and CoreData in iOS

Source: Internet
Author: User

The difference between SQLite and CoreData:

Operation Flow of 1.sqlite database:

Create a database and define a table structure by defining some fields, you can use SQL statements to insert records into a table, delete records, modify records, and create links between tables.

The SQLite and CoreData classes do a correspondence:

Table Structure--------nsentitydescription (menu details)

All the tables in the database and their contact--------Nsmanagedobjectmodel (Recipes)

How the database is stored---------nspersistentstorecoordinator (chef)

Query Statement-----nsfetchrequest (requirements)

Table records------Nsmanagedobject (Entity management Class)

Database operations------Nsmanagedobjectcontext (Miss Waiter)

2.coredata Part Knowledge

Nsentitydescription,nsmanagedobjectmodel

Nsentitydescription is used to define the structure of the table, so you can understand the setentities (Nsarray *) entities function in Nsmanagedobjectmodel is probably useful. The model is usually defined, which is a graphical operation using the file Coredata.xcda****odel, which is similar to creating an interface with NIB.

Create a new project, use CoreData, after the emulator runs, the program corresponding to the document directory appears a coredata.sqlite, you can use the Sqlite3 command to view the structure of the table inside

Nspersistentstorecoordinator

The object of this class is initialized with Nspersistentstorecoordinator object, there are some methods to add, delete Nsmanagedobject

Nsfetchrequest

You typically use nsentitydescription to construct a query, you specify the query for that table, and you can specify a sort

In the CoreData design, the next layer has corresponding properties pointing to the previous layer, so nsmanagedobject has properties to get nsentitydescription,nsentitydescription, There are attributes to get nsmanagedobjectmodel.

As for the class

Nsfetchedresultscotroller, just another seal, and nsfetchrequest together to use, easy to access data, and nsmanagedobjectcontext associated with the database when the change to receive notification

The difference between SQLite and CoreData in iOS

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.