Registering a redo operation from an async undo with NSUndoManager

我只是一个虾纸丫 提交于 2020-05-30 07:43:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!