2 errors occur after migrating to swift 4.
First error:
Initializer for conditional binding must have Optional type, not AVCaptureVideoPreviewLayer.
Second error:
Initializer for conditional binding must have Optional type, not [AVCaptureDevice].
How Should I correct these errors?
Thanks
I think you just remove if let ...
condition and changes
like simple
let cameraLayer = AVCaptureVideoPreviewLayer(session: self.cameraSession)
And same for second error means you should use directly videoDevices
no need to use if let...
condition.
The initializer of AVCaptureVideoPreviewLayer
doesn't return an optional. Thus, the if condition is always true, and the if statement ist useless. You should remove the if and it's braces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With