From 6d6167a5b5ccdba22291ea20628a2e059e2320d1 Mon Sep 17 00:00:00 2001 From: Steve Nicholson Date: Fri, 21 Mar 2014 23:45:53 -0700 Subject: [PATCH] Check that the return value is nil before attempting to do anything with the NSError object Apple's Error Handling Programming Guide (https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ ErrorHandlingCocoa/CreateCustomizeNSError/CreateCustomizeNSError.html) states that return values must be checked for nil or NO before attempting to do anything with the NSError object --- .../Example_MarkerBasedAR/VideoSource.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Chapter2_iPhoneAR/Example_MarkerBasedAR/Example_MarkerBasedAR/VideoSource.mm b/Chapter2_iPhoneAR/Example_MarkerBasedAR/Example_MarkerBasedAR/VideoSource.mm index 5459b7f..2fe6b1a 100644 --- a/Chapter2_iPhoneAR/Example_MarkerBasedAR/Example_MarkerBasedAR/VideoSource.mm +++ b/Chapter2_iPhoneAR/Example_MarkerBasedAR/Example_MarkerBasedAR/VideoSource.mm @@ -146,7 +146,7 @@ - (bool) startWithDevicePosition:(AVCaptureDevicePosition)devicePosition AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error]; self.deviceInput = videoIn; - if (!error) + if (nil != videoIn) { if ([[self captureSession] canAddInput:videoIn]) { @@ -160,7 +160,7 @@ - (bool) startWithDevicePosition:(AVCaptureDevicePosition)devicePosition } else { - NSLog(@"Couldn't create video input"); + NSLog(@"Couldn't create video input: %@", [error localizedDescription]); return FALSE; } }