What is core data ?
Core data is a framework used in macOS to manage the model layer objects in your application. Core data provides a generalized and automated structure with object life cycle and object graph management. Core data reduces upto 50 to 70 percent of code you write to support the model layer. Core data stores the data in different formats,
- Binary format
- In memory store
- SQLLite format
Core data stack
A core data stack is a collection of framework objects. A core data stack is a mediator between an object and an external data store. Stacks consist of 3 primary objects.
- Manage object model : Managed object model is an instance of NSManageObjectModel class that loads the data and exposes it to core data.
- Manage object context : This is the instance of NSManageObjectModel class that your application interacts most.
- Persistent store coordinator : Persistent store coordinator is the heart of the core data stack. It is used to release the instance of an entity.
Advantages of Core data
- Core data is faster than SQLite as it is heavily optimized regarding cache, memory management, and many more things.
- One of the most significant benefits of core data is the lazy loading of data and faulting to save memory.
- Core data maintains forward and backward links whenever objects are added or removed from a relationship.
Limitations of core data
- If you want to delete thousands of data, you have to load every data one by one, which might cause performance issues.
- Core data has no limitations; it sometimes gets imposed with disk space or situational memory.