The Core Data Stack:
is the term used to describe a collection of Core Data framework objects that work together to get
modeled objects from and save data to a persistent store—the file where your data is stored. Conceptually, a persistent store is like a database, with tables and records.
modeled objects from and save data to a persistent store—the file where your data is stored. Conceptually, a persistent store is like a database, with tables and records.
Three main important stack or pillar of core data:
1.Managed object Model :We think this is a core database schema . It is main class that hold the definition of all object(also called entities ), those used in database storing.
Usually, you will use the visual editor you just peeked at to set up
what objects are in the database, what their attributes, and how they
relate to each other.
2.Persistent Store co-coordinator: This is stand for database connection Here’s where you set up the actual names and locations of what databases will be used to store the objects, and any time a managed object context needs to save something it goes through this single coordinator.
3.Managed Object Context: Managed object context take the responsibility for inserting, deleting and modify object definition . when we perform any action inserting, deleting and modify it send to Persistent store Co-coordinator.
Managed Objects and the Managed Object Context:
A managed object is an instance of NSManagedObject or of a subclass of NSManagedObject. Conceptually, it’s an object representation of a record in a table in a database, so it’s a model .
(in the sense of the
model-view-controller design pattern) object that is managed by Core Data. Managed objects represent the data you operate on in your application—for example departments and employees in a human resources application;shapes, text areas, and groups in a drawing application; albums, artists, and tracks in a music management application. A managed object is always associated with a managed object context.
model-view-controller design pattern) object that is managed by Core Data. Managed objects represent the data you operate on in your application—for example departments and employees in a human resources application;shapes, text areas, and groups in a drawing application; albums, artists, and tracks in a music management application. A managed object is always associated with a managed object context.
The managed object context is an instance of NSManagedObjectContext. A context represents a single object space, or scratch pad, in an application. Its primary responsibility is to manage a collection of managed objects. These objects form a group of related model objects that represent an internally consistent view of one or more persistent stores. The context is a powerful object with a central role in your application, with responsibilities from life-cycle management to validation, relationship maintenance, and undo/redo.
When you create a new managed object, you insert it into a context. You fetch existing records in the database into the context as managed objects. (Fetching is discussed in greater detail in “Fetching Events” Any changes you make (whether insertion or deletion of complete objects, or manipulation of property values) are kept in memory until you actually commit them to the store by saving the context.
The Managed Object Model:A managed object model is an instance of NSManagedObjectModel. It’s an object representation of a schema
that describes your database, and so the managed objects you use in your application. A model is a collection of entity description objects (instances of NSEntityDescription). An entity description describes an entity (a table in a database) in terms of its name, the name of the class used to represent the entity in your application, and what properties (attributes and relationships) it has.
that describes your database, and so the managed objects you use in your application. A model is a collection of entity description objects (instances of NSEntityDescription). An entity description describes an entity (a table in a database) in terms of its name, the name of the class used to represent the entity in your application, and what properties (attributes and relationships) it has.
Every managed object has a reference to the entity of which it is an instance.
Core Data uses the model to map between managed objects in your application and records in the database. It’s important to be aware that if you change the schema in your application, Core Data won’t be able to read stores you created using the previous model.
Persistent Store Coordinator :
The persistent store coordinator plays a central role in how Core Data manages data; however, you don’t often interact with the coordinator directly when you use the framework. This section describes the persistent store coordinator in detail, so if you prefer you can skip it and refer to it later as necessary. (The persistent store coordinator is also described in Core Data Basics in the Core Data Programming.
A persistent store coordinator is an instance of NSPersistentStoreCoordinator. It manages a collection
of persistent object stores. A persistent object store represents an external store (file) of persisted data. It’s the object that actually maps between objects in your application and records in the database. There are different classes of persistent object store for the different file types that Core Data supports. You can also implement your own if you want to support a custom file type—see Atomic Store Programming Topics . To learn more about persistent stores and the different types, see Persistent Store Features in Core Data Programming Guide
of persistent object stores. A persistent object store represents an external store (file) of persisted data. It’s the object that actually maps between objects in your application and records in the database. There are different classes of persistent object store for the different file types that Core Data supports. You can also implement your own if you want to support a custom file type—see Atomic Store Programming Topics . To learn more about persistent stores and the different types, see Persistent Store Features in Core Data Programming Guide
No comments:
Post a Comment