Core Data

Persist or cache your app's data on one device, or sync it across devices with CloudKit.

Introduced
2005
Mac OS X 10.4 Tiger
Kind
Framework
Runs on
Get it from
iOS
3.0+
iPadOS
3.0+
Mac Catalyst
13.0+
macOS
10.4+
tvOS
9.0+
visionOS
1.0+
watchOS
2.0+

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.

TripListView.swift
import CoreData import SwiftUI struct TripListView: View { @FetchRequest(sortDescriptors: [SortDescriptor(\.startDate, order: .reverse)]) private var trips: FetchedResults<Trip> var body: some View { List(trips) { trip in Text(trip.name ?? "Untitled") } } }

History

How it grew up.

2005

Mac OS X Tiger

Core Data debuts on the Mac as one of the new technologies in Mac OS X 10.4.

2009

iPhone OS 3

Core Data comes to iPhone and iPod touch with iPhone OS 3.0.

2016

NSPersistentContainer

iOS 10 and macOS 10.12 add one class that sets up the entire Core Data stack.

2019

CloudKit container

iOS 13 adds NSPersistentCloudKitContainer to mirror stores to CloudKit.

2023

SwiftData

SwiftData builds on Core Data's persistence and can share a store with it.