title: How to use result from barcodescanner somewhere else?
body: <p>So i have a barcodescan button, I want to press it and scan an item, then retrieve the barcode and use the retrieved barcode in another button (this will send an api request with the barcode), how would i go about this?</p>
  <p>Would love if someone could point me in the right direction, cant seem to find any answers online (probably searching for the wrong thing).</p>
  <p>Thanks in advance!</p>
  <p>This is partially my code:</p>
  <pre><code>
  import UIKit
  import AVFoundation
  import QRCodeReader
  import Alamofire
  
  
  
  
  class NewViewController: UIViewController, QRCodeReaderViewControllerDelegate {
      
      lazy var readerVC: QRCodeReaderViewController = {
      let builder = QRCodeReaderViewControllerBuilder {
      //change object to scan and the initial position of the camera
          $0.reader = QRCodeReader(metadataObjectTypes: [.qr, .ean13], captureDevicePosition: .back)
  
      // Configure the view controller (optional)
      $0.showTorchButton = true
      $0.showSwitchCameraButton = false
      $0.showCancelButton = true
      $0.showOverlayView = true //shows the square area of the QRCode Scanner
          $0.rectOfInterest = CGRect(x: 0, y: 0, width: 1, height: 1)
          
          //$0.rectOfInterest = CGRect(x: 0.12, y: 0.3, width: 0.8, height: 0.6)
      }
      return QRCodeReaderViewController(builder: builder)
      }()
      
  
      
      
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view.
          readerVC.delegate = self
      
      }
      
      func reader(_ reader: QRCodeReaderViewController, didScanResult result: QRCodeReaderResult) {
      //code to be added
          reader.stopScanning()
          print(result)
          print(result.value) //I WANT TO USE THIS RESULT SOMEWHERE ELSE //ANOTHER BUTTON
          dismiss(animated: true, completion: nil)
      }
  
      func readerDidCancel(_ reader: QRCodeReaderViewController) {
      //code to be added
          reader.stopScanning()
          dismiss(animated: true, completion: nil)
      }
      
      
      
          @IBAction func BARCODESCANNER(_ sender: UIButton) {
  
              readerVC.modalPresentationStyle = .formSheet
              self.present(readerVC, animated: true)
  
             //THIS BUTTON OPENS THE BARCODE SCANNER AND RETRIEVES RESULT IN THE &quot;func reader&quot; ABOVE
          
      }
      
  
      
      @IBAction func ANOTHERBUTTON(_ sender: Any) {
          
          // I WANT TO USE THE RETRIEVED BARCODE HERE WITH MORE CODE FOR AN API REQUEST
          
      }
      
  }
  </code></pre>