Fixing the duplicated scan #127

This commit is contained in:
Yannick Loriot 2017-11-26 22:47:37 +01:00
parent f63c569eda
commit e969a4c5c7
1 changed files with 8 additions and 8 deletions

View File

@ -191,19 +191,19 @@ public final class QRCodeReader: NSObject, AVCaptureMetadataOutputObjectsDelegat
*Notes: if `stopScanningWhenCodeIsFound` is sets to true (default behaviour), each time the scanner found a code it calls the `stopScanning` method.* *Notes: if `stopScanningWhenCodeIsFound` is sets to true (default behaviour), each time the scanner found a code it calls the `stopScanning` method.*
*/ */
public func startScanning() { public func startScanning() {
if !session.isRunning { sessionQueue.async {
sessionQueue.async { guard !self.session.isRunning else { return }
self.session.startRunning()
} self.session.startRunning()
} }
} }
/// Stops scanning the codes. /// Stops scanning the codes.
public func stopScanning() { public func stopScanning() {
if session.isRunning { sessionQueue.async {
sessionQueue.async { guard self.session.isRunning else { return }
self.session.stopRunning()
} self.session.stopRunning()
} }
} }