Ans : Core Data is Apple’s object graph management and persistency framework.
Core Data Stack |
- Managed Object
- Managed Object Context
- Managed Object Model
- Persistent Store Coordinator
NSManagedObject
’s are the model objects exposed by Core Data.NSManagedObjectModel
is a database schema that describes the application’s entities. It defines the structure of the managed objects.NSPersistentStoreCoordinator
associates persistent storage and managed object model. It lends itself to mapping the data from the storage, say SQLite data base rows, into the object model. It is a task of high complexity and is often taken for granted when working with Core Data.What is more, the persistent coordinator is used by the managed object context when it comes to saving or fetching objects.NSManagedObjectContext
controls the life cycle of the managed objects and provides operations to create, save and fetch them. You can think of the managed object context as a scratch pad with a group of managed objects.
Starting from iOS 10,
NSPersistentContainer
is responsible for creation and management of the Core Data stack.NSPersistentContainer
exposes a managed object model, a managed object context and a persistent store coordinator as well as provides many convenience methods when working them, especially when it comes to multithreaded applications.