Core Data
Persist or cache your app's data on one device, or sync it across devices with CloudKit.
Overview
Core Data manages an app's model layer. You describe types and relationships in Xcode's Data Model editor, and Core Data maps those objects to a persistent store. It also tracks changes for undo and redo, runs work in background contexts and migrates data as the model evolves. NSPersistentContainer sets up the whole stack, and NSPersistentCloudKitContainer mirrors stores to a CloudKit private database.
SwiftData, introduced in 2023, combines Core Data's persistence technology with a Swift-native, macro-based API. Its default store uses Core Data underneath, and both frameworks can share one store, so an existing app can adopt SwiftData step by step.
Object persistence
Save and fetch model objects without administering a database directly.
Undo and redo
Roll back changes individually, in groups or all at once.
CloudKit mirroring
Mirror a local store to a CloudKit database to sync across devices.
Model migration
Lightweight, staged and manual migrations keep stores in step with the model.
History
How it grew up.
Mac OS X Tiger
Core Data debuts on the Mac as one of the new technologies in Mac OS X 10.4.
iPhone OS 3
Core Data comes to iPhone and iPod touch with iPhone OS 3.0.
NSPersistentContainer
iOS 10 and macOS 10.12 add one class that sets up the entire Core Data stack.
CloudKit container
iOS 13 adds NSPersistentCloudKitContainer to mirror stores to CloudKit.
SwiftData
SwiftData builds on Core Data's persistence and can share a store with it.