I'm often asked to explain Core Data to the new joiners. 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. Represented 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
What do you think? Let me know by getting in touch on Twitter - @wibosco