Re: Undo Names in NSPersistentDocument
Re: Undo Names in NSPersistentDocument
- Subject: Re: Undo Names in NSPersistentDocument
- From: Jerry Krinock <email@hidden>
- Date: Fri, 18 Dec 2009 23:25:51 -0800
On 2009 Dec 18, at 21:34, Gerriet M. Denkmann wrote:
> I added in MyDocument.m:
>
> - (IBAction)add: sender;
> {
> [ [ self undoManager ] setActionName: @"Add" ];
> [ dictWordArrayController add: sender ];
> }
>
> and now got two Undo items:
I presume you mean that you can click Undo once, and then the item is still enabled, so you click again.
> 1. Undo Add (which does nothing)
> 2. Undo (without name, which undoes the add:)
Yes, it's a fairly well-known issue. Except, you imply that before you added this method, there was only one Undo click available. That's very interesting -- something I'd never noticed. It's as though setting the action name is being registered as an undoable action, and gets thrown on the Undo Stack. So maybe your "does nothing" is actually un-setting the action name ?!?!?
I have a work in progress which solves this problem by beginning an undo grouping whenever a managed object changes, and the same method ends it "automatically" via performSelector:withObject:afterDelay:. The idea is that it swallows up whatever Core Data does into one super-undo-group. It works pretty good but I'm still ironing it out.
For another solution, you should read this:
http://wilshipley.com/blog/2007/12/transitions-and-epiphanies.html
_______________________________________________
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