Merge pull request #130 from kabanishe23/bugfix_120

Get ride of lazy init of previewLayer. Fixes #120
This commit is contained in:
Yannick Loriot 2018-02-17 21:39:28 +01:00 committed by GitHub
commit eaf911bc97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -75,9 +75,7 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat
// MARK: - Managing the Properties // MARK: - Managing the Properties
/// CALayer that you use to display video as it is being captured by an input device. /// CALayer that you use to display video as it is being captured by an input device.
public lazy var previewLayer: AVCaptureVideoPreviewLayer = { public let previewLayer: AVCaptureVideoPreviewLayer
return AVCaptureVideoPreviewLayer(session: self.session)
}()
/// An array of object identifying the types of metadata objects to process. /// An array of object identifying the types of metadata objects to process.
public let metadataObjectTypes: [AVMetadataObject.ObjectType] public let metadataObjectTypes: [AVMetadataObject.ObjectType]
@ -128,7 +126,7 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat
*/ */
public init(metadataObjectTypes types: [AVMetadataObject.ObjectType], captureDevicePosition: AVCaptureDevice.Position) { public init(metadataObjectTypes types: [AVMetadataObject.ObjectType], captureDevicePosition: AVCaptureDevice.Position) {
metadataObjectTypes = types metadataObjectTypes = types
previewLayer = AVCaptureVideoPreviewLayer(session: session)
super.init() super.init()
sessionQueue.async { sessionQueue.async {