Implementing Undo and Redo with the Command Design Pattern in Swift

Using UndoManager to create an Undoable History

Undo and redo are two common functions found in many apps and your users may expect it in your app as well. Whenever it’s possible to manipulate data, your users will be grateful when they can undo their errors. Imagine using Xcode without the possibility to undo your latest change or redo it again — it would be a horror!

This gif shows an example of how undo and redo work:
The three buttons “Red”, “Blue” and…