Re: More on Undo and Redo
Re: More on Undo and Redo
- Subject: Re: More on Undo and Redo
- From: Graham Cox <email@hidden>
- Date: Fri, 20 Feb 2009 15:28:31 +1100
On 20/02/2009, at 6:34 AM, Randall Meadows wrote:
when changing a yellow object blue, you pass the Undo manager the
object, the -setColor: method, and the current color, so that upon
invoking Undo the color is changed back to what it was. Nice and
symmetrical.
However, I have a case where symmetry is not involved.
Undo isn't *required* to be symmetrical. It just happens to be when
setting a single property like your -setColor: example.
Another very common situation is like this:
- (void) addObject:(id) obj
{
[[undoManager prepareWithInvocationTarget:self] removeObject:obj];
[array addObject:obj];
}
- (void) removeObject:(id) obj
{
[[undoManager prepareWithInvocationTarget:self] addObject:obj];
[array removeObject:obj];
}
This code will undo and redo adding and removing objects all day long.
Each undo is complementary to the other, but it's not identical.
Seems to me this is the sort of design you want.
--Graham
_______________________________________________
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