title: quartz-core: Undo for a paint app in iOS
body: <p>I create a paint app for iOS using the quartz-core framework, what should I do if I want to add the Undo function?</p>
  
  <p>Here are some code fragment:</p>
  
  <pre><code>- (void)drawRect:(CGRect)rect
  {
      CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextSetLineWidth(context, 5.0);
      CGContextSetLineCap(context, kCGLineCapRound);
      [drawColor set];
      for (Line *line in linesCompleted) {
          [[line color] set];
          CGContextMoveToPoint(context, [line begin].x, [line begin].y);
          CGContextAddLineToPoint(context, [line end].x, [line end].y);
          CGContextStrokePath(context);
      }
  }
  </code></pre>