title: How to capture picture with AVCaptureSession in Swift?
body: <p>I have a <code>UIViewController</code> in which I use <code>AVCaptureSession</code> to show the camera and it is working just fine and fast. I placed a <code>UIButton</code> object on top of this camera view and added a <code>IBAction</code> for the button.</p>
  
  <p>This is how it looks like right now:</p>
  
  <p><img src="https://i.stack.imgur.com/IxDg1.jpg" alt="my camera app"></p>
  
  <p>Now I want to get the picture of the current camera view when the user taps the button:</p>
  
  <pre><code>@IBAction func takePicture(sender: AnyObject) {
      // omg, what do do?!
  }
  </code></pre>
  
  <p>I have no idea whatsoever on how I can do that. I imagined there could have been something like:</p>
  
  <pre><code>let captureSession = AVCaptureSession()
  var myDearPicture = captureSession.takePicture() as UIImage // something like it?
  </code></pre>
  
  <p>The full link for the controller code is here <a href="https://gist.github.com/rodrigoalvesvieira/392d683435ee29305059" rel="noreferrer">https://gist.github.com/rodrigoalvesvieira/392d683435ee29305059</a>, hope it helps</p>