2016-10-12 3 views

Répondre

1

Les seuls changements devraient être la partie protocole, vous pouvez vous référer à ce post.

How to import Zbar Framework in Swift Project

extension ZBarSymbolSet: Sequence { 
    public func makeIterator() -> NSFastEnumerationIterator { 
     return NSFastEnumerationIterator(self) 
    } 
} 

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { 
    // ADD: get the decode results 
    let results: NSFastEnumeration = info[ZBarReaderControllerResults] as! NSFastEnumeration 

    var symbolFound : ZBarSymbol? 

    for symbol in results as! ZBarSymbolSet { 
     symbolFound = symbol as? ZBarSymbol 
     break 
    } 
    let resultString = symbolFound!.data 
    print(resultString) 
}