I'm currently having an issue trying to pass data from a QR Code scanner controller to a view controller. The reason for doing this is because I'm gonna have 30+ Qr codes during an event, and all these codes will segue to the same view controller but with different label/data.
View Controller
var myString:String = ""
@IBOutlet var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
label?.text = myString
}
QR Scanner Controller
func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let secondController = segue.destination as! Sample3Controller
if segue.identifier == "Segue1"
{
secondController.myString = "Welcome to Booth 1"
}
else if segue.identifier == "Segue2"
{
secondController.myString = "Welcome to Booth 2"
}
}
if metadataObj.stringValue == "Booth 1" //if qr code text is "Booth1"
{
captureSession?.stopRunning()
self.performSegue(withIdentifier: "Segue1", sender: self)
}
else if metadataObj.stringValue == "Booth 2" // if qr code text is "Booth2"
{
captureSession?.stopRunning()
self.performSegue(withIdentifier: "Segue2", sender: self)
}