UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

New app lifecycle and undoManager

Forums > SwiftUI

Currently I have my AppDelegate be an NSWindowDelegate so that I can make windowWillReturnUndoManager return the undoManager of my viewContext. This makes undo/redo work in sync with any NSManagedObject changes.

Is this functionality possible with the new app lifecycle (@main, App and Scene)? There is an undoManager in Environment, but you can't set it yourself, and there's no clue as to how it is set by the framework. It seems to work automatically if for example a TextField is first responder, but it does not work for my own custom view that is an NSResponder with an undoManager behind a NSViewRepresentable.

2      

Hello I am looking into this too, it is not working the @Environment(.undoManager) is nil and the worst is that it rely on document saving.

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.