Skip to content

Commit

Permalink
Fix: In case that were no features found, it would not throw any erro…
Browse files Browse the repository at this point in the history
…r, and also it uses force cast
  • Loading branch information
tataruRobert committed Aug 21, 2024
1 parent 34da57f commit d89df51
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Sources/CodeScanner/ScannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -512,17 +512,22 @@ extension CodeScannerView.ScannerViewController: UIImagePickerControllerDelegate

let features = detector.features(in: ciImage)

for feature in features as! [CIQRCodeFeature] {
qrCodeLink = feature.messageString!
if qrCodeLink.isEmpty {
didFail(reason: .badOutput)
} else {
if features.isEmpty {
didFail(reason: .badOutput)
} else {
for feature in features.compactMap({ $0 as? CIQRCodeFeature }) {
guard let qrCodeLink = feature.messageString, !qrCodeLink.isEmpty else {
didFail(reason: .badOutput)
continue
}

let corners = [
feature.bottomLeft,
feature.bottomRight,
feature.topRight,
feature.topLeft
]

let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg, corners: corners)
found(result)
}
Expand Down

0 comments on commit d89df51

Please sign in to comment.