2

I am writing a non-NSDocument-based application similar in style to, say, AddressBook.app. It has a single window located in MainMenu.nib.

Currently, I am struggling with integrating NSUndoManager with this application. If I create an instance of NSUndoManager and store it into an instance variable of my AppController class, the "Undo" menu item doesn't get enabled on registering undos with the manager.

What do I have to do in order to connect the NSUndoManager instance to the menu items and have it manage the window's dirty state?

tajmahal
  • 1,665
  • 3
  • 16
  • 29

1 Answers1

4

You can create in your AppDelegate class, your undo manager as member of the class.Then you set AppDelegate to be the delegate of the window in interface builder.After this you write this method in AppDelegate:

- (NSUndoManager*) windowWillReturnUndoManager: (NSWindow*) window
{
    < return the undo manager created >
}
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187