eliu2016 / Swap

Repository for iOS Application - Swap
2 stars 1 forks source link

Upload Swap Code #67

Closed MichealSBingham closed 7 years ago

MichealSBingham commented 7 years ago
    /// Returns the swap link from a Swap Code read from an UIImage. Will return "" if none is      found.
  func swapCodeLinkFrom(Image image: UIImage) -> String {

var swapLink = ""

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

if let detector = detector{

    if let ciimage = CIImage(image: image){

        var features = detector.features(in: ciimage)

        for feature in features{

            let decodedCode = (feature as! CIQRCodeFeature).messageString

            swapLink = decodedCode ?? ""
        }

    }

}

return swapLink

 }