Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Detect text messages from QR code
extension UIImage {
func parseQR() -> [String] {
guard let image = CIImage(image: self) else {
return []
let detector = CIDetector(ofType: CIDetectorTypeQRCode,
context: nil,
options: [CIDetectorAccuracy: CIDetectorAccuracyHigh])
let features = detector?.features(in: image) ?? []
return features.compactMap { feature in
return (feature as? CIQRCodeFeature)?.messageString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.