Member-only story
WWDC 2023: Meet Swift Data
This isn’t Core Data
5 min readJun 22, 2023
This article is intended as a companion to Apple’s video and does not replace it in any way. However, I find having a text file like this much more helpful than just a video but I’m sure you’ll let me know in the comments how useful this is.
Swift Data
Uses the new Swift Macros to make this seamless.
In the repo I’ve added my project with the files, and to make this work in the storage section I selected Swift Data.
Model Macro
@Model
defines scheme with code. This adds functionality with additional metadata by decorating a model with the annotation @Model
import SwiftData
@Model
class Trip {
var name: String
var destination: String
var endDate: Date
var startDate: Date
var bucketList: [BucketListItem]? = []
var livingAccommodation: BucketListItem?
}