Fatal Error in QRCode Scanner App for IOS
<p>I am working on an QRCode Scanner App for IOS with two Views. When I compile and launch the App on my iPad 2 and click my button on the toolbar I get an EXC_BREAKPOINT with subcode 0xe77ffdefe on both classes.</p>

<pre><code>class ViewController: UIViewController {

@IBAction func showQRView(sender: AnyObject){

    let secondView:QRCodeViewController = QRCodeViewController()
    self.presentViewController(secondView, animated: true, completion: nil)

}//end of showQRView



override func viewDidLoad() {
    super.viewDidLoad()





}



override func didReceiveMemoryWarning() {
     super.didReceiveMemoryWarning()



}}
</code></pre>

<p><strong>Second Class</strong></p>

<pre><code>class QRCodeViewController: UIViewController,AVCaptureMetadataOutputObjectsDelegate {
@IBAction func closeView(sender:AnyObject)
self.dismissViewControllerAnimated(true, completion: nil)
}

@IBOutlet weak var messageLabel:UILabel!

var captureSession:AVCaptureSession?
var videoPreviewLayer:AVCaptureVideoPreviewLayer?
var qrCodeFrameView:UIView?a

let supportedBarCodes = [AVMetadataObjectTypeQRCode, AVMetadataObjectTypeCode128Code, AVMetadataObjectTypeCode39Code, AVMetadataObjectTypeCode93Code, AVMetadataObjectTypeUPCECode, AVMetadataObjectTypePDF417Code, AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypeAztecCode]





override func viewDidLoad() {
    super.viewDidLoad()

    messageLabel.frame = CGRectMake(0, 0, 768, 71)
    messageLabel.backgroundColor = UIColor.blackColor()
    messageLabel.textColor = UIColor(colorLiteralRed: 0.0, green: 255.0, blue: 0.0, alpha: 1.0)
    messageLabel.textAlignment = NSTextAlignment.Center

    let captureDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo)

    do {
        let input = try AVCaptureDeviceInput(device: captureDevice)

        captureSession = AVCaptureSession()
        captureSession?.addInput(input)

        let captureMetadataOutput = AVCaptureMetadataOutput()
        captureSession?.addOutput(captureMetadataOutput)

        captureMetadataOutput.setMetadataObjectsDelegate(self, queue: dispatch_get_main_queue())

        captureMetadataOutput.metadataObjectTypes = supportedBarCodes

        videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
        videoPreviewLayer?.videoGravity = AVLayerVideoGravityResizeAspectFill
        videoPreviewLayer?.frame = view.layer.bounds
        view.layer.addSublayer(videoPreviewLayer!)

        captureSession?.startRunning()

        view.bringSubviewToFront(messageLabel)

        qrCodeFrameView = UIView()

        if let qrCodeFrameView = qrCodeFrameView {
            qrCodeFrameView.layer.borderColor = UIColor.greenColor().CGColor
            qrCodeFrameView.layer.borderWidth = 2
            view.addSubview(qrCodeFrameView)
            view.bringSubviewToFront(qrCodeFrameView)
        }

    } catch {
        print(error)
        return
    }

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()

}

func captureOutput(captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [AnyObject]!, fromConnection connection: AVCaptureConnection!) {

    if metadataObjects == nil || metadataObjects.count == 0 {
        qrCodeFrameView?.frame = CGRectZero
        messageLabel.text = "No QR code is detected"
        return
    }


    let metadataObj = metadataObjects[0] as! AVMetadataMachineReadableCodeObject


    if supportedBarCodes.contains(metadataObj.type) {

        let barCodeObject = videoPreviewLayer?.transformedMetadataObjectForMetadataObject(metadataObj)
        qrCodeFrameView?.frame = barCodeObject!.bounds

        if metadataObj.stringValue != nil {
            messageLabel.text = metadataObj.stringValue
        }
    }
}
</code></pre>

<p>}</p>