I was switching the Detector scanner from QR to Rectangle type of detection but on Rectangle type of detection I cannot take the feature.messageString out of CIRectangleFeature, while on CIQRCodeFeature it works. Only what I had changed was ofType: CIDetectorTypeQRCode into CIDetectorTypeRectangle and features as? [CIQRCodeFeature] into features as? [CIRectangleFeature]
here is the code
func processQRCodeImage(_ image: UIImage) {
var qrCodeLink = ""
let detector: CIDetector = CIDetector(ofType: CIDetectorTypeRectangle, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh])!
let ciImage: CIImage = CIImage(image: image)!
let features = detector.features(in: ciImage)
if let features = features as? [CIRectangleFeature] {
for feature in features {
qrCodeLink += feature.messageString! // Value of type 'CIRectangleFeature' has no member 'messageString' COMPILE ERROR
}
}
if qrCodeLink.isEmpty {
failedQRCoderead()
} else {
found(code: qrCodeLink)
onBackPressed?()
}
}