I contacted the developer of RSBarcodes_Swift on this issue . To perform any UI operation, it must be started in the main thread. For example, the segue function should be changed from:
func performQR(){
self.performSegueWithIdentifier("toQR", sender: self)
}
to
func performQR(){
dispatch_async(dispatch_get_main_queue(), { () -> Void in
self.performSegueWithIdentifier("toQR", sender: self)
})
}
To avoid multiple repetition of scan time, the call self.session.stopRunning()with breakcan be used in a loop barcodesfor processing.
self.barcodesHandler = { barcodes in
for barcode in barcodes {
println("Barcode found: type=" + barcode.type + " value=" + barcode.stringValue)
if let builtObject = self.ObjectHelper.validateAndBuild(barcode,
scannedData: barcode.stringValue){
println("Good object.")
self.finalObject = builtObject
self.session.stopRunning()
self.performQR()
break
}
}
}
source
share