The error message most likely happened because you changed the class name so the current SwiftData schema was different from what the existing store had used, as discussed here. I don't think that is the root cause of your issue. What catches my eyes is that you commented out the modelContext.save(). SwiftData supports auto-save, and yet, auto-save happens periodically. If you stop running your app before auto-save happens, the data will not be persisted. Other than that, I don't see any obvious issue in your code snippets. If you can share a runnable code that reproduces the issue, I may take another look. Best, —— Ziqiao Chen Worldwide Developer Relations.
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: