Core Data Introduction for iOS & iPhone

iOS Tutorials: Core Data Stack

What is Core Data?

Core Data is a kind of framework is build around SQLite, so that we can manage the model object layer. In a nutshell if we talk about model then it’s the other name given to DATA.

Core Data helps in decreasing the amount of code which we write in order to manage/support the  model layer.

It we talk about features then they are listed below:

  • Maintenance of Changes.
  • Tracking changes.
  • Automatic Validation.
  • Lazy Loading of objects.
  • Version Tracking
  • Simple Query writing with the help of NSPredicate etc

Core Data Stack

iOS Tutorials: Core Data Stack
Core Data Stack

Managed Object Content: It provided a scratchpad for managed objects.

Managed Object Models: It describes entity in the store.

Persistent Store Coordinator: It contains all the stores.

Persistent Object Store: Its a kind of mapping between records in the store and Objects in the Application.

Note: An External Persistent Store contains all the records.

What is a Managed Object?

It represents a record from a Persistent Store. If we talk in the sense of MVC(Model View Controller )pattern then Managed Object is the object of the model. It registers itself with the Managed Object Context.

Class Used while implementation: NSManagedObject

iOS Tutorials: Managed Object
Managed Object

What is a Managed Object Context?

It represents a single object space or as stated earlier a Scratchpad in a Core Data Application. It primary responsibility is to maintain all the objects of Managed Object.

Class Used while implementation: NSManagedObjectContext

iOS Tutorials: Managed Object Context
Managed Object Context

What is a Persistent Store Coordinator?

It is an association between persistent object store and the managed object models. It has a reference to a managed object model that describes the entities in the store or stores it manages. Many Applications have single store but the applications with complex architecture has Multiple Stores. We need to specify the store at the time of Data retrieval.

Class Used while implementation: NSPersistentStoreCoordinator

 Please check out our next article on how to Insert, Update, Delete Records using Core Data from the link.

Author: Chandra.rao

iOS Developer. #Life of an developer.... Learn New technology, Code, Learn New Technology, Code, Death.