title: Turn on torch/flash on iPhone
body: <p>I know that the only way to turn on the flash and keep it on on iPhone 4 is by turning the video camera on. I'm not too sure of the code though. Here is what I am trying:</p>
  
  <pre><code>-(IBAction)turnTorchOn {
      AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
      AVCaptureDevice *videoCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
      NSError *error = nil;
      AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoCaptureDevice error:&amp;error];
  
      if (videoInput) {
          [captureSession addInput:videoInput];
  
          AVCaptureVideoDataOutput* videoOutput = [[AVCaptureVideoDataOutput alloc] init];
          [videoOutput setSampleBufferDelegate:self queue:dispatch_get_current_queue()];
  
          [captureSession addOutput:videoOutput];
  
          [captureSession startRunning];
  
          videoCaptureDevice.torchMode = AVCaptureTorchModeOn;
      }   
  }
  </code></pre>
  
  <p>Does anybody know if this would work or am I missing anything? (I don't have an iPhone 4 yet to test on -just trying out some of the new API's).</p>
  
  <p>Thanks</p>