title: Getting CIImage from UIImage (Swift)
body: <p>Trying to obtain CIImage from UIImage in order to use it for CIFilter, but getting the following exception at the last line: </p>
  
  <pre><code>Execution was interrupted, reason: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <pre><code>import UIKit
  
  UIGraphicsBeginImageContextWithOptions(CGSizeMake(100,100), false, 0)
  let con:CGContextRef = UIGraphicsGetCurrentContext()
  CGContextAddEllipseInRect(con, CGRectMake(0,0,100,100))
  CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
  CGContextFillPath(con)
  let im:UIImage = UIGraphicsGetImageFromCurrentImageContext()
  UIGraphicsEndImageContext()
  
  let ciimage = CIImage(image: im) // &lt;- Exception here
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  Following the advice not to instantiate CIImage as a variable I reworked my initial code snippet to work in a playground:</p>
  
  <pre><code>UIGraphicsBeginImageContextWithOptions(CGSizeMake(100,100), false, 0)
  let con:CGContextRef = UIGraphicsGetCurrentContext()
  CGContextAddEllipseInRect(con, CGRectMake(0,0,100,100))
  CGContextSetFillColorWithColor(con, UIColor.blueColor().CGColor)
  CGContextFillPath(con)
  let im:UIImage = UIGraphicsGetImageFromCurrentImageContext()
  UIGraphicsEndImageContext()
  
  //let ciimage = CIImage(image: im) // &lt;- this was causing an exception
  
  let filter = CIFilter(name: "CIGaussianBlur", withInputParameters: [kCIInputRadiusKey: 10, kCIInputImageKey: CIImage(image: im)]) // &lt;- this does not cause an exception
  let calayer = CALayer()
  calayer.contents = CIContext(options:nil).createCGImage(filter.outputImage, fromRect: filter.outputImage.extent())
  calayer.frame = CGRect(x: 0, y: 0, width: 270, height: 270)
  var view = UIView()
  view.frame = calayer.frame
  view.layer.addSublayer(calayer)
  XCPShowView("view", view)
  </code></pre>