title: Swift - Using CGContext to draw with finger
body: <p>I'm trying to make a drawing app. I have a single custom UIView:</p>
  
  <pre><code>class DrawView: UIView {
  
  var touch : UITouch!
  var lastPoint : CGPoint!
  var currentPoint : CGPoint!
  
  override func touchesBegan(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent) {
      touch = touches.first as! UITouch
      lastPoint = touch.locationInView(self)
      println(lastPoint)
  }
  
  override func touchesMoved(touches: Set&lt;NSObject&gt;, withEvent event: UIEvent) {
      touch = touches.first as! UITouch
      currentPoint = touch.locationInView(self)
  
      self.setNeedsDisplay()
  
      lastPoint = currentPoint
  }
  
  override func drawRect(rect: CGRect) {
      var context = UIGraphicsGetCurrentContext()
      CGContextSetLineWidth(context, 5)
      CGContextSetStrokeColorWithColor(context, UIColor.blueColor().CGColor)
      CGContextSetLineCap(context, kCGLineCapRound)
  
      CGContextBeginPath(context)
  
      if lastPoint != nil {
          CGContextMoveToPoint(context, lastPoint.x, lastPoint.y)
          CGContextAddLineToPoint(context, currentPoint.x, currentPoint.y)
      }
  
      CGContextStrokePath(context)
  }
  
  }
  </code></pre>
  
  <p>When I run it, however, all I get is a blue dot that follows my finger, but no lines?</p>
  
  <p>What am I doing wrong?</p>