Search code examples
ioscocoa-touchundo-redonsundomanager

Undoing older actions than the most recent one, using NSUndoManager or some other class


I'm developing an app in which a "non-sequential" undo mechanism is desirable for a certain type of actions. With non-sequential I mean that actions can be undone selectively and without regard to their order in history (for example: having 5 actions, I can undo any of them without affecting the remaining ones). So my question is, is this possible with NSUndoManager or some other similar class? Or do I have to implement this functionality myself?

Update: What I want to accomplish is analogous to having a sum to which I can add or subtract numbers. These additions and subtractions may then be undone in any possible order (this will not give any undesirable side-effects as all values are valid for the sum).


Solution

  • hard to know if this will work for you, but I have used a collection of undo managers and "activated" them based on context. If your actions cant be separated that way then that raises the question if your actions can be separated at all.

    Typically, an action depends on the state produced by the previous actions and trying to undo an action that occurred before the most recent action cannot be undone completely or produces undesirable side effects.

    You are going to have to be more specific about what you are trying to accomplish.