NSUndoManager with Core Data - Redo not working
Posted
by CJ
on Stack Overflow
See other posts from Stack Overflow
or by CJ
Published on 2010-03-10T18:10:57Z
Indexed on
2010/05/02
4:57 UTC
Read the original article
Hit count: 376
I have a Core Data document-based app which support undo/redo via the built-in NSUndoManager associated with the NSManagedObjectContext. I have a few actions set up which perform numerous tasks within Core Data, wrap all these tasks into an undo group via beginUndoGrouping
/endUndoGrouping
, and are processed by the NSUndoManager.
Undo works fine. I can perform several successive actions, and each then undo each one of them successively and my app's state is maintained correctly. However, the "Redo" menu item is never enabled. This means that the NSUndoManager is telling the menu that there are no items to redo.
I am wondering why the NSUndoManager is seemingly forgetting about items once they are undone, and not allowing redos to occur?
One thing I should mention is that I'm disabling undo registration after a document is opened/created. When I perform an action, I call enableUndoRegistration
, beginUndoGrouping
, perform the action, then call processPendingChanges
, setActionName:
, endUndoGrouping
, and finally disableUndoRegistration
. This makes sure that only specific actions are undoable, and any other data changes I make outside of these go unnoticed to the NSUndoManager. This may be a part of the issue, but if so I'm wondering why it's affecting redo?
Thanks in advance.
© Stack Overflow or respective owner