- Feb 13, 2024
What's the difference between SwiftData and Core Data?
- Mark Moeykens
- SwiftUI
I got this question enough that I decided to put together a post.
What can both do?
Both are data persistence frameworks.
Get, insert, update, and delete data.
Display data easily with SwiftUI
Create relationships between two models/entities.
Sync data between all of a user's devices using CloudKit.
(Setting up SwiftData example from: SwiftData Mastery in SwiftUI)
What is different?
SwiftData is newer and only available since iOS 17 where Core Data supports all versions.
Core Data supports shared and public CloudKit databases. This is when different users of your app can see each other's data.
Core Data has a sectioned fetch request which can make it easy to bind to a List/Form with sections:
(Sectioned fetch request example from: Core Data Mastery in SwiftUI)
SwiftData Advantages
Less of a learning curve.
Faster and easier to set up models and get data on the screen.
Automatically saves data, no need to manually save.
Easy to create models in Swift with compiler type-checking built in.
(Creating a model is as easy as making a class in Swift. From: SwiftData Mastery in SwiftUI)
Learn More - Special Offer
Are you interested in advancing your skills with SwiftData or Core Data easily and visually?
We offer books to help you do just that!
As a thank you for reading our blog, we're thrilled to offer you an exclusive 11% discount on all our SwiftUI books!
📚 Use coupon code POSTS_11 at checkout or just click this link bigmountainstudio.com to claim your discount.
(Note: Coupons cannot be used during sales.)
Your Learning Path Quick Links (Save 11%)
Create UI with SwiftUI Views Mastery (beginner)
Architect your app using SwiftUI Essentials (beginner)
Improve your app's UX with SwiftUI Animations Mastery (junior)
Save & sync your app's data with Core Data Mastery -or- SwiftData Mastery (junior)
React to and manipulate data using Combine Mastery in SwiftUI (advanced)