             let readableObject = lastMetadataObject as? AVMetadataMachineReadableCodeObject
         {
             if (readableObject.type == AVMetadataObjectTypeQRCode) {
-                captureSession?.stopRunning()
                 // Construct a forum object with the scanned result.
                 if let jsonData = readableObject.stringValue.dataUsingEncoding(NSUTF8StringEncoding),
                     let jsonDict = (try? NSJSONSerialization.JSONObjectWithData(jsonData,

class ForumQRScannerViewController: UIViewController {
    
    @IBOutlet var cameraPreviewView: UIView!
    var captureSession: AVCaptureSession?
    var capturedForum: KomicaForum?
    
    private struct SegueIdentifier {
        static let addForum = "addForum"

                {
                    capturedForum = KomicaForum(jsonDict: jsonDict)
                    if ((capturedForum?.isReady()) != nil) {
                        captureSession?.stopRunning()
                        performSegueWithIdentifier(SegueIdentifier.addForum, sender: nil)
                        return
                    }
                }
            }
        }
        if warningAlertController == nil {
            // Cannot parse.
            warningAlertController = UIAlertController(title: "QR code cannot be parsed, please try again", message: nil, preferredStyle: .Alert)
            warningAlertController?.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: { (_) in
                self.warningAlertController = nil
            }))
            presentViewController(warningAlertController!, animated: true, completion: nil)
        }
    }
    
}
