Search code examples
qr-codeios11swift4

AVCaptureMetadataOutputObjectsDelegate not called in swift 4 for QR scanner


I was working on QR code scanner app on iOS where i was getting output AVCaptureOutput on the delegate method captureOutput:didOutputMetadataObjects:fromConnection:.

It was working perfectly on swift 3. After I've updated to xcode 9 and swift 4, it stopped working.


Solution

  • Okay I've found an update here.

    Found that AVCaptureMetadataOutputObjectsDelegate method is changed

    from

    captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!)
    

    to

    metadataOutput(_ output: AVCaptureMetadataOutput, didOutput metadataObjects: [AVMetadataObject], from connection: AVCaptureConnection)
    

    After changing this delegate method, its working good now.