BrT

Musings about technology and other neat stuff

BrT random header image

WILTAC #4: Undo

November 19th, 2008 · No Comments

Today I learned how to add support for undo/redo operations using NSUndoManager. This was completely new to me, and I was surprised at how cleverly done it is – essentially, for every operation that you want to undo, you provide the “inverse” operation, and NSUndoManager takes care of keeping them in appropriate stacks for undo/redo, and even of enabling/disabling the corresponding menu items.

As I advance through the book, I am more amazed at how much support Cocoa provides for all sorts of things. On an interesting counterpoint, I was surprised to see how complicated it is to automatically begin editing an entry in a table after inserting it. I would have expected the corresponding NSArrayController to support this, since it is such a common thing to do.

Tags: · · ·