From c8605d523a0756e925b2ca28ad74e0148b9c79a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Torra=CC=83o?= Date: Wed, 6 Jul 2016 14:34:01 +0100 Subject: [PATCH] add error checking --- camera/ViewController.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/camera/ViewController.swift b/camera/ViewController.swift index 57ab2e8..a146caf 100644 --- a/camera/ViewController.swift +++ b/camera/ViewController.swift @@ -97,11 +97,16 @@ class ViewController: UIViewController { switch (cameraManager.cameraOutputMode) { case .StillImage: cameraManager.capturePictureWithCompletion({ (image, error) -> Void in - let vc: ImageViewController? = self.storyboard?.instantiateViewControllerWithIdentifier("ImageVC") as? ImageViewController - if let validVC: ImageViewController = vc { - if let capturedImage = image { - validVC.image = capturedImage - self.navigationController?.pushViewController(validVC, animated: true) + if let errorOccured = error { + self.cameraManager.showErrorBlock(erTitle: "Error occurred", erMessage: errorOccured.localizedDescription) + } + else { + let vc: ImageViewController? = self.storyboard?.instantiateViewControllerWithIdentifier("ImageVC") as? ImageViewController + if let validVC: ImageViewController = vc { + if let capturedImage = image { + validVC.image = capturedImage + self.navigationController?.pushViewController(validVC, animated: true) + } } } })