Giter Site home page Giter Site logo

Comments (11)

yeahdongcn avatar yeahdongcn commented on August 24, 2024
func performQR(){
    dispatch_async(dispatch_get_main_queue(), { () -> Void in
        self.performSegueWithIdentifier("toQR", sender: self)
    })
}

You need to switch to main thread to perform UI related operations.

from rsbarcodes_swift.

yeahdongcn avatar yeahdongcn commented on August 24, 2024

The barcodesHandler was designed non thread safe, because we may perform some actions which may take long time.

from rsbarcodes_swift.

yeahdongcn avatar yeahdongcn commented on August 24, 2024

Could you try the code I provided?

from rsbarcodes_swift.

drewantonich avatar drewantonich commented on August 24, 2024

Thank you very much for the reply. I am unable to test the code tonight, but I will tomorrow.

from rsbarcodes_swift.

drewantonich avatar drewantonich commented on August 24, 2024

I tested the code and it does perform the segue. My only issue now is that the segue is performed multiple times and doesn't just stop after a valid scan happened. Is there a way to stop the scanning process immediately after a valid scan took place?

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){ // If built object is valid
                self.performQR() // End scanning here and perform segue once
        }
    }
}

from rsbarcodes_swift.

yeahdongcn avatar yeahdongcn commented on August 24, 2024

You can add a break after you call self.performQR()

from rsbarcodes_swift.

drewantonich avatar drewantonich commented on August 24, 2024

Unfortunately, adding the break still causes multiple segues to occur. A solution I found is to add self.session.stopRunning() before self.performQR() and then add a break. Is it safe to stop the session like this?

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){ // If built object is valid
                self.finalObject = builtObject // Assign finalObject for segue purposes
                self.session.stopRunning()
                break
        }
        else {
            self.displayInvalidScan()
        }
    }
    self.handleSegue()
}

from rsbarcodes_swift.

yeahdongcn avatar yeahdongcn commented on August 24, 2024

Yeah, you're right, I forgot this line.

from rsbarcodes_swift.

drewantonich avatar drewantonich commented on August 24, 2024

I posted this conversation to SO to be more reachable.

from rsbarcodes_swift.

yeahdongcn avatar yeahdongcn commented on August 24, 2024

Great, thank you!

from rsbarcodes_swift.

Gerst20051 avatar Gerst20051 commented on August 24, 2024

👍

from rsbarcodes_swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.