Skip to content

Instantly share code, notes, and snippets.

@freak4pc
Created August 26, 2018 08:37
Show Gist options
  • Select an option

  • Save freak4pc/3f7ae2801dd8b7a068daa957463ac645 to your computer and use it in GitHub Desktop.

Select an option

Save freak4pc/3f7ae2801dd8b7a068daa957463ac645 to your computer and use it in GitHub Desktop.
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
}
}
}
@nayabbuttfp
Copy link
Copy Markdown

it does not work for iOS Simulator 14.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment