• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: More on Undo and Redo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: More on Undo and Redo
      • From: Jerry Krinock <email@hidden>
References: 
 >More on Undo and Redo (From: Randall Meadows <email@hidden>)

  • Prev by Date: Can't create windows with framework window nib
  • Next by Date: sdp generating empty header
  • Previous by thread: Re: More on Undo and Redo
  • Next by thread: Re: More on Undo and Redo
  • Index(es):
    • Date
    • Thread