In work, I'm often asked to explain Core Data to the new joiners in the team. I thought I'd share what I tell them about the components that make up Core Data:
- Persistent store - is where Core Data stores its data, more often in a form of a SQLLite database but can be Atomic (binary store) or In-Memory.
- NSPersistentStoreCoordinator - controls access to the persistent store - save, retrieve and search.
- NSManagedObjectModel - representation of data model in memory, can combine multiple persistent stores into one. Respresented by .xcdatamodel files
- NSManaagedObjectContext - a scratch pad that contains all NSManagedObjects that have been created or loaded, handles changes to these objects and handles committing these change to the persistent store when you tell it to. This allows to for undo functionality to be added to your application.
- Entities - data model class, like a normal Objective-C class declaration.
- NSManagedObject - data object that represents a row in an entity.
- Attributes - can be thought of instance variables of a normal Objective-C class.
- Relationships - association between two different entities, can be as a "to one" or "to many" relationship.
- Fetched properties - can be thought of as a weak relationship between nsmanagedobjects in an entity.
- Fetch Requests - Can be thought of as a query against the entity. They come in two forms:
- Originates outside the entity
- Saved inside the entity (this can be thought of as a class method)
What do you think? Let me know by getting in touch on Twitter - @wibosco