views:

44

answers:

1

So I followed the WWDC session 409 about using the camera/flash/torch/etc as a device on the iPhone 4 and I was able to write the chuck of code below. It's compiles without any errors but when I try the execute it on my iPhone 4 nothing happens. Can someone help me figure out what i've done wrong. I'm also trying to get the torch to turn on instantaneously so if anyone has any suggestions as to how i can do that I would really appreciate it.

- (IBAction)toggleTorch {

 AVCaptureSession *session = [[AVCaptureSession alloc] init];

 AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

 AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
 [session addInput:input];

 AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
 [session addOutput:output];

 [session beginConfiguration];

 [device lockForConfiguration:nil];
 [device setTorchMode:AVCaptureTorchModeOn];
 [device unlockForConfiguration];

 [session commitConfiguration];

 [session startRunning];

 [output release];
 [session release];

}
A: 

It seems there's a lot of information here

KevinDTimm
well the thing is that i've tried that before but now i'm trying to get the torch to turn on and off instantaneously and using that method does not help me there. Please any advice on how I would go about doing that would be really appreciated
cgossain