CIDetectorTypeQRCode

I want to get QRcode string from Image. I am using as following.

let detector:CIDetector=CIDetector(ofType: CIDetectorTypeQRCode, context: nil, options: [CIDetectorAccuracy:CIDetectorAccuracyHigh])!


It works fine in device but when generating build for itunes distribution it gives error :

"Value of type '[String:AnyObject]?" has no member 'Key'.


If I remove the option part ([CIDetectorAccuracy:CIDetectorAccuracyHigh]) then it gives error like :

'(ofType: String, context: CIContext?, options: [String : AnyObject]?) -> CIDetector' is not convertible to '(ofType: String, context: CIContext?, options: [String : AnyObject]?) -> CIDetector?'


Anyone have idea about this? I am using swift 2.3 and XCode 8.1. Any Help will be appreciated.

I don't know why you are getting the "has no member 'Key'" error, but the other one is because you are specifying a non-optional type on tghe left side, but the function you are calling returns an optional. You would have to write it this way if you don't want the ! on the end of the right side:

let detector:CIDetector?=CIDetector(ofType: CIDetectorTypeQRCode, context: nil, options: [CIDetectorAccuracy:CIDetectorAccuracyHigh])

or, leave the type off of the left side (it will still be an optional CIDetector, but you are letting Xcode figure that out):

let detector=CIDetector(ofType: CIDetectorTypeQRCode, context: nil, options: [CIDetectorAccuracy:CIDetectorAccuracyHigh])
CIDetectorTypeQRCode
 
 
Q