How to use AVCapturePhotoOutput : <p>I have been working on using a custom camera, and I recently upgraded to Xcode 8 beta along with Swift 3. I originally had this:</p>

<pre><code>var stillImageOutput: AVCaptureStillImageOutput?
</code></pre>

<p>However, I am now getting the warning:</p>

<blockquote>
  <p>'AVCaptureStillImageOutput' was deprecated in iOS 10.0: Use AVCapturePhotoOutput instead</p>
</blockquote>

<p>As this is fairly new, I have not seen much information on this. Here is my current code:</p>

<pre><code>var captureSession: AVCaptureSession?
var stillImageOutput: AVCaptureStillImageOutput?
var previewLayer: AVCaptureVideoPreviewLayer?

func clickPicture() {

    if let videoConnection = stillImageOutput?.connection(withMediaType: AVMediaTypeVideo) {

        videoConnection.videoOrientation = .portrait
        stillImageOutput?.captureStillImageAsynchronously(from: videoConnection, completionHandler: { (sampleBuffer, error) -&gt; Void in

            if sampleBuffer != nil {

                let imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(sampleBuffer)
                let dataProvider = CGDataProvider(data: imageData!)
                let cgImageRef = CGImage(jpegDataProviderSource: dataProvider!, decode: nil, shouldInterpolate: true, intent: .defaultIntent)

                let image = UIImage(cgImage: cgImageRef!, scale: 1, orientation: .right)

            }

        })

    }

}
</code></pre>

<p>I have tried to look at <code>AVCapturePhotoCaptureDelegate</code>, but I am not quite sure how to use it. Does anybody know how to use this? Thanks.</p>
