twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
1.02k stars 293 forks source link

Use View controller as a coordinator #30

Closed breyed closed 2 years ago

breyed commented 3 years ago

The implementation in CodeScanner.swift creates a coordinator instance to adopt AVCaptureMetadataOutputObjectsDelegate. Is there an advantage to using a coordinator instead of having ScannerViewController adopt the delegate?

The intent of a coordinator in SwiftUI seems to be to host delegates when you're using an existing ViewController. In this case, since a custom ViewController is needed, there doesn't seem to be any need for a second class.

nathanfallet commented 2 years ago

I'm going to take a look if this refactor can be done and works.