Skip to content

Commit

Permalink
self is not nil before proceeding in a block of code, which can help …
Browse files Browse the repository at this point in the history
…prevent runtime errors related to unwrapping a nil optional value.
  • Loading branch information
hajunho committed Feb 13, 2024
1 parent bbba45c commit f546b1d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Sources/WeScan/Scan/CaptureSessionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,13 @@ final class CaptureSessionManager: NSObject, AVCaptureVideoDataOutputSampleBuffe
}
case .notDetermined:
AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: { [weak self] granted in
if granted {
DispatchQueue.main.async {
self?.start()
}
} else {
DispatchQueue.main.async {
DispatchQueue.main.async {
guard let self = self else { return }
if granted {
self.start()
} else {
let error = ImageScannerControllerError.authorization
self?.delegate?.captureSessionManager(self!, didFailWithError: error)
self.delegate?.captureSessionManager(self, didFailWithError: error)
}
}
})
Expand Down

0 comments on commit f546b1d

Please sign in to comment.