I am experiencing issues following iOS Databases where SwiftData is not being persisted on the simulator. I also downloaded the course files and ran Chris’ project and experience the same data loss each time the app is restarted. Any thing I should check?
If i manually call context.save()
after an insert or update the data is persisted. I don’t think I am missing anything here.
import SwiftUI
import SwiftData
@main
struct SwiftDataDemoApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.modelContainer(for: DataItem.self)
}
}
}