Demonstrating a problem with NSUndoManager and UITextView
This project demonstrates an issue posted on Stack Overflow here and on Apple forums here. Basically, if you programmatically change the text of a UITextView
, its undo manager seems to clear its undo stack, even if you undo your changes properly.
To repro:
- Run project
- Type some changes in the text view
- Tap the Emoji button, and an emoji is inserted
- Type some more changes
- Begin undoing all your changes
You can undo back to the addition of the emoji (because that operation is done through the undo manager), but no further. If at step 3 you select some text and add a strikethrough, though, you can undo all of your changes.