Use NSUndoManager. However, if you draw lines on the canvas, you will also need to keep their view around (so that you can turn them off).
So, whether you collect them as UIBezierPath or use form layers or your own "array of points", you cancel in the same way.
, , , . (, touchEnded), "" , . , - -...
- (void)pushDrawing:(Drawing*)drawing
{
[self.stack push:drawing];
[self.undoManager registerUndoWithTarget: self
selector: @selector(popDrawing)
object: nil];
}
- (void)popDrawing:(Drawing*)drawing
{
Drawing *drawing = [self.stack pop];
[self.undoManager registerUndoWithTarget: self
selector: @selector(pushDrawing:)
object: drawing];
}
, , . , ...
NSUndoManager... iOS . "", , , ( , ).