Re: NSUndoManager setActionName: oddity
Re: NSUndoManager setActionName: oddity
- Subject: Re: NSUndoManager setActionName: oddity
- From: Kyle Sluder <email@hidden>
- Date: Mon, 02 Jul 2012 08:25:45 -0700
On Jul 2, 2012, at 2:35 AM, Conrad Shultz <email@hidden> wrote:
> - (void)addRecord:(id)sender
> {
> if (! [[self undoManager] isUndoing]) {
> [[self undoManager] setActionName:NSLocalizedString(@"Add Record", nil)];
> }
> [[self arrayController] add:sender];
> }
IIRC, you need to put the call to -setActionName: *after* the action that opens the undo group. Which I don't see you doing here, but I suppose you're relying on it happening as a side effect of whatever the array controller does?
This is because NSUndoManager is a very old class with a very weird internal data structure that can't attach an action name without an object at the top of its stack. You might investigate using Graham Cox's GCUndoManager.
FWIW, we put all our undo actions in the model because of AppleScript, but that makes our model single-threaded.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden