I am trying to make a QR code scanner. However, it keeps saying that the scanner is not in scope. How can I fix this?
Cannot find type "..." in scope
When I select line 8, I get
QRSkannerController
instead of
QRScannerController
Why a : after class ?
class:QRSkannerController:UIViewControlle @Cannotfindtype'QRScannerController'inscope
It is probably not the exact code. You cannot define a class in its extension…
So please post real code and we'll see what happens.
Declare your QRScannerController class first...
...then add the extension code, like this:
class QRScannerController: UIViewController {
var video = AVCaptureVideoPreviewLayer()
var qrcodeFrameView = UIView() // this needs to be initialized to something
override func viewDidLoad() {
super.viewDidLoad()
// creating session
let session = AVCaptureSession()
}
}
extension QRScannerController: AVCaptureMetadataOutputObjectsDelegate {
// add delegate methods here...
}
You have to define the QRScannerController
. Since you added your class inside an extension, it the compiler won't be able to find what QRScannerController
is.