SwiftData rollback not updating the UI
I’m building a simple App using SwiftData. In my app a user can create, remove and edit posts. When editing, I want them to be able to hit “Save” to persist the changes or “Cancel” to discard the changes. The approach I’m using is to disable autosave and call modelContext.save()
when saving and modelContext.rollback()
when discarding the changes. So my modelContainer
is defined as follows:
How to properly add data files into a SwiftData ModelDocument file package
I am working on a macOS/iOS sandboxed app with SwiftUI/SwiftData. The app saves its’ data into a ModelDocument file. But I want to also save large binary data files into this file.
How to embed SwiftData model container in a custom file package document type
I have done a lot of research on this but am not able to come up with a workable solution to this problem. My knowledge and experience in Swift and SwiftUI/SwiftData/AppKit/UIKit is limited so I am probably not seeing the problem correctly to come up with a solution.