I think I must be missing something fundamental, or have a misunderstanding to begin with. Or maybe I'm just doing something wrong to begin with...

I'm working on an app, implementing Undo features. Undo basics are simple: you supply the Undo manager an object, a method, and some arguments that effectively "mirror" the operation just [about to be] performed: 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. The program manages "cards"; it uses custom code to manage the backing store file, which is in a cross-platform format (i.e., it uses open, seek, write, close et al, instead of, say, writing out dictionaries).

One of the operations I need to support Undo for is Delete Card. When a card is deleted, the data in the file is deleted, and the GUI removes an entry from the array controller managing the display. In order to support Undo, I cache all the pertinent information that the card would normally hold onto, and upon Undo being invoked, I recreate a new card from scratch. (I cannot hold onto the card object itself because it loads its data lazily; data is not loaded from the file until it actually needs to be displayed on screen. So if I held onto the object itself, some fields would be nil, and once the data is deleted from the file, I can no longer get it back in order to restore it. Not that this is really pertinent to my real question...)

I have Undo working just great: I delete a card, I cache its attributes with the Undo manager, it gets deleted from the file, it's removed from the display, I Undo, a new card gets created and populated with the cached attributes, saved in the file and displayed, all is well in the world.

The problem is Redo. This is not a symmetric operation, like changing the color of an object on screen. All I need to do to Redo is call the method that deletes the card. It seems I need to tell the Undo manager to invoke a different method, with different arguments, when Redo is invoked, but I've not found how to do that.

Anyone care to set me straight on this?


Thanks!
randy
_______________________________________________

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