How to import Zbar Framework in Swift Project

大城市里の小女人 提交于 2019-12-05 21:43:24

for Swift 3:

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)
    }
ErcanE

Here is the solution

following link helped me https://stackoverflow.com/a/24005242/4059179

But after that I had NSEnumeration Problem so here second problem solution

func imagePickerController(picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [NSObject : AnyObject]){
var results: NSFastEnumeration = info[ZBarReaderControllerResults] as NSFastEnumeration
} 

Don't forget to extend

extension ZBarSymbolSet: SequenceType { public func generate() -> NSFastGenerator { return NSFastGenerator(self) } 
}
surga

I have this project

Using cocoapods to import the ZBarSDK to Swift 2.0 project.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!