Post

Replies

Boosts

Views

Activity

Comment on Enabling undo with multi-model schema
Unlike the Hacking with Swift article, I set my undo manager from the environment and it works. The only catch you can't do in the app context, it has to be on a view level. In any content view, we can access undo manager through the @Environment(\.undoManager) var undoManager, then when I create my content view I initiate the background task using the .task modifier, and setting the under manager: modelContext.undoManager = undoManager. It's probably not a best practice though.
Dec ’23