Core Data stack

https://developer.apple.com/library/content/documentation/DataManagement/Devpedia-CoreData/coreDataStack.html#//apple_ref/doc/uid/TP40010398-CH25-SW1

A Core Data stack is composed of the following objects: one or more managed object contexts connected to a single persistent store coordinator which is in turn connected to one or more persistent stores. A stack contains all the Core Data components you need to fetch, create, and manipulate managed objects. Minimally it contains:

  • An external persistent store that contains saved records.

  • A persistent object store that maps between records in the store and objects in your application.

  • A persistent store coordinator that aggregates all the stores.

  • A managed object model that describes the entities in the stores.

  • A managed object context that provides a scratch pad for managed objects.

Art/single_persistent_stack.jpg

A stack is effectively defined by a persistent store coordinator—there is one and only one per stack. Creating a new persistent store coordinator implies creating a new stack. By implication, there is therefore only one model, although it may be aggregated from multiple models. There may be multiple stores—and hence object stores—and multiple managed object contexts.

A managed object context is usually connected directly to a persistent store coordinator, but may be connected to another context in a parent-child relationship.

原文地址:https://www.cnblogs.com/feng9exe/p/7449460.html