title: UIBezierPath Stroke (and Fill) in Swift
body: <p>I'm struggling to find a way to stroke (and fill) a Bezier path in swift. Here's what I thought would work but doesn't.</p>
  
  <pre><code>var myBezier = UIBezierPath()
  myBezier.moveToPoint(CGPoint(x: 0, y: 0))
  myBezier.addLineToPoint(CGPoint(x: 100, y: 0))
  myBezier.addLineToPoint(CGPoint(x: 50, y: 100))
  myBezier.closePath()
  UIColor.setStroke(UIColor.blackColor())
  myBezier.stroke()
  </code></pre>
  
  <p>The line <code>UIColor.setStroke(UIColor.blackColor())</code> gives me this error in the console:</p>
  
  <pre><code>Playground execution failed: error: &lt;REPL&gt;:51:1: error: expression
  resolves to an unused function UIColor.blackColor())
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  </code></pre>
  
  <p>The line <code>myBezier.stroke()</code> gives me this set of errors:</p>
  
  <pre><code>Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextSaveGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextSetLineWidth: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextSetLineJoin: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextSetLineCap: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextSetMiterLimit: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextSetFlatness: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextAddPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextDrawPath: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  Jul 19 12:07:46 Computer-MacBook-Pro.local [20579] &lt;Error&gt;: CGContextRestoreGState: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context  and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.
  </code></pre>
  
  <p>In Objective-C, I would use something like this but, this is obviously not going to work in Swift.</p>
  
  <pre><code>[[UIColor blackColor] setStroke]
  [myBezier stroke]
  </code></pre>
  
  <p>Any Sugestions?</p>