 
   // MARK: - AVCaptureMetadataOutputObjects Delegate Methods
 
-  public func metadataOutput(captureOutput: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
+  public func metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection) {
     for current in metadataObjects {
       if let _readableCodeObject = current as? AVMetadataMachineReadableCodeObject {
         if _readableCodeObject.stringValue != nil {

      }
    }


    metadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
    metadataOutput.metadataObjectTypes = metadataObjectTypes
    previewLayer.videoGravity          = AVLayerVideoGravity.resizeAspectFill
  }

  /// Switch between the back and the front camera.


/// Reader object base on the `AVCaptureDevice` to read / scan 1D and 2D codes.
public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegate {
  private let sessionQueue         = DispatchQueue(label: "session queue")
  private let metadataObjectsQueue = DispatchQueue(label: "com.yannickloriot.qr", attributes: [], target: nil)
  
  var defaultDevice: AVCaptureDevice = AVCaptureDevice.default(for: AVMediaType.video)!
  var frontDevice: AVCaptureDevice?  = {
    if #available(iOS 10, *) {
      return AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front)
    }
    else {
      for device in AVCaptureDevice.devices(for: AVMediaType.video) {
        if device.position == .front {
          return device
        }
      }
