Use when working with Core Data in this iOS codebase — migrating context usage, fixing merge conflicts, modernizing the stack, or reviewing Core Data patterns.
saveWithBlock(_:completion:) to avoid blocking the calling thread.Stack lives in TCCoreData/Sources/Core Data Stack/. Central class: TTCoreDataStack (@objc).
NSPersistentStoreCoordinator
│
readOnlyRootContext ← private-queue; PSC-connected; the persisting root (name is misleading — not read-only)
│
mainQueueContext ← main-queue child; used by FetchedResultsControllers and most read callers
│
"Worker contexts" (n) ← private-queue children created on demand via newChildContext(); destroyed after each block
Key APIs on TTCoreDataStack:
newChildContext() — creates a new private-queue child of mainQueueContext on every callcontextForThread() — caches one child context per thread description ("\(Thread.current)"); keys are unstablesaveWithBlockAndWait(_:) / saveWithBlock(_:) — create an ephemeral child, run a block, save up the parent chaindataOperationQueue — serial OperationQueue for SSE/socket writespersistedAPICallsOperationQueue — unlimited OperationQueue for persisted API requestsenqueueDataBlock, enqueueSSEDataBlock, enqueueHighPriorityDataBlock, enqueueVeryLowPriorityDataBlock, enqueuePersistedAPIOperationBlockParty (Abstract)
├── User → Patient, PatientContact, Role
└── Group → RoleGroup
All subclasses share one table. Concurrent writes from any context collide at the row level — the primary source of merge conflicts.
Heavy-write non-inherited entities: Message, RosterEntry, MessageStatus, UploadItem, DownloadItem.