Code for undo/redo

Am using textview : This is Apple code from DTS...not functional.

class TextStore: ObservableObject { @Published var text = " " let undoManager = UndoManager()

@objc func setText(_ newText: String) {
    let oldText = text
    text = newText

    undoManager.registerUndo(withTarget: self, handler: {
        $0.setText(oldText)
    })
}

}

Button(b70){if textStore.undoManager.canUndo{textStore.undoManager.undo()} Button(b71){if textStore.undoManager.canRedo{textStore.undoManager.redo()}

                }
                    
                }
Code for undo/redo
 
 
Q