From 2262a42a256a0dee32d36f7d8ddd468b60505aff Mon Sep 17 00:00:00 2001 From: Mark Schuette Date: Thu, 22 Jan 2015 13:30:13 +0100 Subject: [PATCH] only add input to the session if there is an input This will prevent NSInvalidArgumentException on iOS8 in case the permission for the camera was revoked in the settings. --- Classes/NBNImageCaptureCell.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Classes/NBNImageCaptureCell.m b/Classes/NBNImageCaptureCell.m index e1076ce..eff6190 100644 --- a/Classes/NBNImageCaptureCell.m +++ b/Classes/NBNImageCaptureCell.m @@ -41,7 +41,10 @@ - (void)setupImagePicker { AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error = nil; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; - [captureSession addInput:input]; + + if (input) { + [captureSession addInput:input]; + } AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:captureSession]; captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;