Edit AllPages

There is scant (or hard to find) information on how to support undo within a modal sheet in a Cocoa application. I’ve managed to get it working, so thought I’d document it here.

I came across the NSPersistentDocument Core Data Tutorial (, which has a section on supporting Undo in a sheet.

Unfortunately, the code in the document doesn’t do everything related to undo/redo - the menu titles aren’t updated for some reason. To get undo/redo working properly in a sheet, follow these steps:

  1. Implement the changes and workarounds mentioned in the tutorial (above).

  2. Modify the targetForAction:to:from: method in your NSApplication subclass to modify the menu item titles, so it looks like:

– JeremyHiggs