I have a CoreData based application which supports shake-to-undo. This is currently working fine, however when I shake the device, the undo happens immediately, without first showing the usual undo prompt which NSUndoManager normally provides for free.
I've read "Using Undo on iPhone" from the "Undo Architecture" document and am:
canBecomeFirstResponder
, returning YES
becomeFirstResponder
in viewDidAppear
resignFirstResponder
in viewDidDisappear
self.undoManager
in the view controller as read/writeNSUndoManager
and setting self.undoManager
in the UIViewController
init
method (which I've verified is getting called).self.managedObjectModel.managedObjectContext.undoManager
to self.undoManager
in the setter for managedObjectModel
. Again, I've verified this is getting called. If I don't do this, undo doesn't work at all.Troubleshooting I've already tried:
canBecomeFirstResponder
is being calledself.undoManager
is being called during an undo operation (which it is not).So my questions are:
I eventually tracked this down to some legacy code which was manually catching the shaking motion and calling undo on the undoManager; an implementation of motionEnded: in the view controller. Once this was removed, I started getting undo prompts again.