Here, I will save basic coredata information for anyone/me would like a quick refresh for these fundamentals from time to time.
- Core Data is not a database, but instead it manages an Object Graph.
-
NSManagedObject
andNSManagedObjectContext
in Core Data are not thread-safe. -
Core Data avoids data race issues by operating on
NSManagedObject
instances andNSManagedObjectContext
instances in a serial queue.
This is why we need to place the operation code within the closures of perform or performAndWait. -
Developers should perform operations on the main thread queue for the view context and the managed object instances registered within it. Similarly, we should perform operations on the serial queue created by the private context for private contexts and the managed objects registered within them.
- Enable Core Data Concurrency Debugging Parameters
To void issues like .......... to be continued
ModelContext
of SwiftUI is like a wrapped version ofNSManagedObjectContext
References:
-
Core Data Fundamentals - Exploring the Core Data Stack
https://cocoacasts.com/exploring-the-core-data-stack -
Concurrent Programming in SwiftData https://betterprogramming.pub/concurrent-programming-in-swiftdata-c9bf021a4c2d
Managed Object Context
It is an instance of
NSManagedObjectContext
class.An app can have one or more managed object context.
It is the object you interact with most.
It Creates, Reads, Updates, Deletes Managed Objects.
Each managed object context manages a collection of Managed Objects.

It receives the Managed Object through a Persistent Store Coordinator
