WILTAC #4: Undo

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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s