Skip to content

Commit 746c1c1

Browse files
authored
Merge pull request #149 from tataruRobert/my-feature-branch
2 parents 9fa582f + d89df51 commit 746c1c1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Sources/CodeScanner/ScannerViewController.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,22 @@ extension CodeScannerView.ScannerViewController: UIImagePickerControllerDelegate
513513

514514
let features = detector.features(in: ciImage)
515515

516-
for feature in features as! [CIQRCodeFeature] {
517-
qrCodeLink = feature.messageString!
518-
if qrCodeLink.isEmpty {
519-
didFail(reason: .badOutput)
520-
} else {
516+
if features.isEmpty {
517+
didFail(reason: .badOutput)
518+
} else {
519+
for feature in features.compactMap({ $0 as? CIQRCodeFeature }) {
520+
guard let qrCodeLink = feature.messageString, !qrCodeLink.isEmpty else {
521+
didFail(reason: .badOutput)
522+
continue
523+
}
524+
521525
let corners = [
522526
feature.bottomLeft,
523527
feature.bottomRight,
524528
feature.topRight,
525529
feature.topLeft
526530
]
531+
527532
let result = ScanResult(string: qrCodeLink, type: .qr, image: qrcodeImg, corners: corners)
528533
found(result)
529534
}

0 commit comments

Comments
 (0)