Skip to content

Commit 6d6167a

Browse files
committed
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
1 parent 8736df1 commit 6d6167a

File tree

1 file changed

+2
-2
lines changed
  • Chapter2_iPhoneAR/Example_MarkerBasedAR/Example_MarkerBasedAR

1 file changed

+2
-2
lines changed

Chapter2_iPhoneAR/Example_MarkerBasedAR/Example_MarkerBasedAR/VideoSource.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ - (bool) startWithDevicePosition:(AVCaptureDevicePosition)devicePosition
146146
AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
147147
self.deviceInput = videoIn;
148148

149-
if (!error)
149+
if (nil != videoIn)
150150
{
151151
if ([[self captureSession] canAddInput:videoIn])
152152
{
@@ -160,7 +160,7 @@ - (bool) startWithDevicePosition:(AVCaptureDevicePosition)devicePosition
160160
}
161161
else
162162
{
163-
NSLog(@"Couldn't create video input");
163+
NSLog(@"Couldn't create video input: %@", [error localizedDescription]);
164164
return FALSE;
165165
}
166166
}

0 commit comments

Comments
 (0)