Which store types does Core Data support?
Essence
The store type is set when a store is attached to the coordinator (NSPersistentStoreDescription.type). On iOS three built-in types are available:
- SQLite (
NSSQLiteStoreType) — the default and almost always the choice. Data lives in a.sqlitefile (plus-waland-shmwith WAL journaling). It's the only type that supports lazy loading,fetchBatchSize, indexes and batch requests: a fetch runs as SQL and only what's needed is brought into memory. - Binary (
NSBinaryStoreType) — the whole graph is serialised into one binary file and loaded into memory entirely. Atomic writes but no partial loading; fine for small data sets. - In-Memory (
NSInMemoryStoreType) — nothing is written to disk. For unit tests, SwiftUI previews and temporary caches.
XML (NSXMLStoreType) exists only on macOS — a human-readable format for debugging; it's not available on iOS.
Beyond the built-ins you can write your own store — an NSIncrementalStore subclass (e.g. over a REST API or another database).
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep