DevPrep

All topics › Databases & storage

What is SwiftData and how does it differ from Core Data?

Middle PRO

Essence

SwiftData (iOS 17+) is a pure-Swift persistence framework on top of the same engine as Core Data (the default store is SQLite, and the format is compatible). The schema is described not in .xcdatamodeld but directly in code with the @Model macro; queries are type-safe through #Predicate, and SwiftUI integration comes via @Query and .modelContainer(for:).

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store