title: iPhone flashlight app crashes when button is tapped fast
body: <p>I got my flashligh app working perfectly. For some reason tho, everytime i tap on the flashlight button really fast, the app just freezes and doesnt do anything. It seems that its freezing when i call the AVCaptureSession stopRunning. Heres the code for my toggle flashlight method. I also want this method to eventually be called for a strobe feature.</p>
  
  <pre><code>- (void)toggleFlashlight{
  
    if (isTorchOn) {
  
     // Start session configuration
     [session beginConfiguration];
  
     [device lockForConfiguration:nil];    
     // Set torch to on
     [device setTorchMode:AVCaptureTorchModeOn];
  
     [device unlockForConfiguration];
     [session commitConfiguration];
  
    [session startRunning];
  
  
   }
   else {
    [session stopRunning];
    [session release]; 
    session = nil;
  
    session = [[AVCaptureSession alloc] init];
  
    // Create device input and add to current session
    AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error: nil];
    [session addInput:input];
  
    // Create video output and add to current session      
    AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
    [session addOutput:output];
    [output release];
   }
  }
  </code></pre>