This is a braindead simple question, but I couldn't find a definitive reference.

Is it better to register an undo action inside or outside of a group?

i.e., is this preferred:

[someUndoManager beginUndoGrouping];
//do interesting things

//end group first
[someUndoManager endUndoGrouping];
//then register undo statement
[someUndoManager registerUndoWithTarget:self @selector(undoSomehow:)
object:magicalObject];

Or is this:

[someUndoManager beginUndoGrouping];
//do interesting things

//first register undo statement
[someUndoManager registerUndoWithTarget:self @selector(undoSomehow:)
object:magicalObject];
//then end group
[someUndoManager endUndoGrouping];


I'd always done it the former way, closing my group first and then
registering my undo target, and as far as I could tell it worked fine.
But in trying to debug an issue, I reached a point where I started
getting exceptions about registering my undo statement when no group
had been begun. So on a whim, I swapped it to the second method, and
that seems to have been the cure for what ailed me.

But now I'm trying to confirm if that is a correct fix, or if it's
just masking some other issue in my code (well, or both, I suppose).

-Jim....
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to