问题
With UndoManager.registerUndo(withTarget:selector:object:) I can register an undo operation, and in the provided selector calling this same method again causes the registration of a redo operation. This works fine unless in the selector I'm calling an async function which then needs to register the redo operation, like this:
func job() {
doSomething()
registerUndo(self, undo)
}
func undo() {
async {
doSomethingElse()
registerUndo(self, job)
}
}
In this case, both calls to registerUndo() actually register an undo operation, and not an undo and then a redo as I would expect. Is there a solution to this problem?
来源:https://stackoverflow.com/questions/58617402/registering-a-redo-operation-from-an-async-undo-with-nsundomanager