使用 zbar sdk 并转换为 swift 3,可以吗?
Using zbar sdk and converting to swift 3, will it work?
我打算将代码转换为Swift 3 in xCode 8,但我犹豫是否这样做,因为我使用的框架,尤其是ZBar SDK(我'我用 CocoaPods 得到它)。有谁知道,转换是否会使这个(或其他)框架无法使用?
唯一的变化应该是协议部分,你可以参考这个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)
}
我打算将代码转换为Swift 3 in xCode 8,但我犹豫是否这样做,因为我使用的框架,尤其是ZBar SDK(我'我用 CocoaPods 得到它)。有谁知道,转换是否会使这个(或其他)框架无法使用?
唯一的变化应该是协议部分,你可以参考这个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)
}