i don\'t understand why this code doesn\'t work, the detector is always nil with the CIDetectorTypeQRCode constant, everything work with CIDetectorTypeFace. I Supect a bug f
I found that using on a device resolved this issue. The simulator seemed to always return nil for me.
This happened to us as well. iPhone 4s doesn't return a CIDetector of type QRCode. The other types (rectangle, face) work though…
The same code works as expected on the iPhone 6. Haven't tested on a 5 or 5s yet.
But two weeks ago it was still working on the 4s, I believe. It was still on iOS 8 back then, I guess.
The code you provided can't have a nil detector
because it's not an optional and the compiler would complain about several places in your code if it was.
If features is empty then you know it didn't find a QR code in your image. Try providing a better image or turning down the CIDetectorAccuracy
.
If features isn't empty then your cast is failing.
Edit:
You can't pass a nil
context in the constructor.
for feature in features as! [CIQRCodeFeature]
.