title: Swift Barcode Scanning
body: <p>I am attempting add barcode scanning to my app using <a href="https://github.com/yeahdongcn/RSBarcodes_Swift" rel="nofollow">RSBarcodes</a>.  I'm having two issues: Not being able to update a label that displays the barcode scanned and the delegate to send the barcode to my calling view controller not working.  Below is my code for the view controller that handles the scanning:</p>
  
  <pre><code>import UIKit
  import AVFoundation
  import RSBarcodes
  
  class ScanViewController: RSCodeReaderViewController {
  @IBOutlet weak var label1Label: UILabel!
  @IBOutlet weak var label2Label: UILabel!
  @IBOutlet weak var scanLabel: UIButton!
  
  var delegate: barcodesScannedDelegate?
  var codes:[String] = []
  override func viewDidLoad() {
      super.viewDidLoad()
  
      var code=""
      // Do any additional setup after loading the view.
      focusMarkLayer.strokeColor = UIColor.redColor().CGColor
  
      cornersLayer.strokeColor = UIColor.yellowColor().CGColor
  
      tapHandler = { point in
          //println(point)
      }
  
      barcodesHandler = { barcodes in
  
          for barcode in barcodes {
              if !contains(self.codes, barcode.stringValue) {
                  self.codes.append(barcode.stringValue)
                  code = barcode.stringValue
              }
  
          }
          println(code)
          self.label1Label.text = code
      }
  
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  @IBAction func finishedPressed(sender: UIButton) {
      delegate?.barcodesScanned(self.codes)
      self.dismissViewControllerAnimated(true, completion: nil)
  }
  
  @IBAction func cancelPressed(sender: UIButton) {
      self.dismissViewControllerAnimated(true, completion: nil)
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Just to ensure I did the delegate correctly, here is my code in Protocol.swift:</p>
  
  <pre><code>protocol selectCarrierDelegate {
     func selectCarrier(carrierID: String,carrier: String)
  }
  
  protocol barcodesScannedDelegate {
      func barcodesScanned(barcodes: [String])
  }
  </code></pre>
  
  <p>And the relevant code in the controller that should receive the barcode:</p>
  
  <pre><code>class InBoundViewController: UIViewController,selectCarrierDelegate,UIAlertViewDelegate,UITableViewDelegate,UITableViewDataSource,barcodesScannedDelegate {
  
  func barcodesScanned(barcodes: [String]) {
      println("codes=\(barcodes)")
  }
  </code></pre>
  
  <p>Anyone have any ideas why the label won't change and the delegate isn't working?</p>