Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Enabling undo in a CoreData app?



I have a CoreData app, and I don't want the user to be able to undo almost all actions. So, during my -applicationDidFinishLaunching method, I disableUndoRegistration on my managedObjectContext.

Now, I want to add undo/redo in a couple specific situations. During one method, I am calling this:

NSUndoManager *undoManager = [[self managedObjectContext] undoManager];
[undoManager enableUndoRegistration];
[[undoManager prepareWithInvocationTarget:self] addObjects:validRemovals toCollection:collection];
(If I am not isUndoing, I call -setActionName: here with some appropriate text)
[undoManager disableUndoRegistration];


And during the -addObjects method, I am calling the compliment:


NSUndoManager *undoManager = [[self managedObjectContext] undoManager];
[undoManager enableUndoRegistration];
[[undoManager prepareWithInvocationTarget:self] removeObjects:validAdditions fromCollection:collection];
(If I am not isUndoing, I call -setActionName: here with some appropriate text)
[undoManager disableUndoRegistration];


However, my "Undo" menu item never becomes enabled. Am I being too picky about when I am enabling and disabling registration? (I briefly tried leaving undo registration turned on throughout the application, but the Undo menu item still never became available.)

Any thoughts for how to track down the problem are appreciated.

Thanks,
Blake



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.