registerUndoWithTarget:selector:object: in or outside of group?
registerUndoWithTarget:selector:object: in or outside of group?
- Subject: registerUndoWithTarget:selector:object: in or outside of group?
- From: Jim Thomason <email@hidden>
- Date: Thu, 24 Feb 2011 16:05:07 -0600
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 (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