Reputation: 1675
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?
Upvotes: 2
Views: 589
Reputation: 21996
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 >
}
Upvotes: 4