WWDC21 SALE: Save 50% on all my Swift books and bundles! >>

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.

   

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.

   

Save money with our WWDC sale!

SAVE 50% To celebrate WWDC21, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.

Save 50% on all our books and bundles!

Reply to this topic…

You need to create an account or log in to reply.

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.