6 Class captureDeviceClass = NSClassFromString(
@"AVCaptureDevice");
7 if (captureDeviceClass != nil)
9 AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
10 if ([device hasTorch] && [device hasFlash])
12 [device lockForConfiguration:nil];
15 [device setTorchMode:AVCaptureTorchModeOn];
16 [device setFlashMode:AVCaptureFlashModeOn];
20 [device setTorchMode:AVCaptureTorchModeOff];
21 [device setFlashMode:AVCaptureFlashModeOff];
23 [device unlockForConfiguration];