I'm trying to add undo and redo functionality to my implementation of a UITextView. I am using attributedText and not simply the text property of the UITextView. I've tried using the function calls in undoManager as cited in the Apple documentation, however nothing seems to be happening. I was surprised that I could not find anything on the subject by Googling. Has anyone encountered this issue before / implemented undo and redo on a UITextView with attributedText / knows how to go about this?
Sample Code
textView.attributedText = NSMutableAttributedString(string: "SOME TEXT")
@objc func undo(_ sender: UIButton) {
textView.undoManager?.undo()
}
@objc func redo(_ sender: UIButton) {
textView.undoManager?.redo()
}