I'm trying to run a void saveImageToLibrary
when
[self.avSnapper captureStillImageAsynchronouslyFromConnection:captureConnection
completionHandler:handler];
is done. How would I go about it?
I'm trying to run a void saveImageToLibrary
when
[self.avSnapper captureStillImageAsynchronouslyFromConnection:captureConnection
completionHandler:handler];
is done. How would I go about it?
If you need to run some code at function completion, there is "completionHandler" parameter.
According to documentation: "A block to invoke after the image has been captured.".
Edit: You can read about blocks programming here. As a block notation can be a bit confusing, there is a simple trick that may help you. When you create function signature in XCode using autocompletion, you have blue placeholders for variables you need to pass. Now, when you hit 'enter' on block placeholder, XCode generates empty block with matching syntax for you.
I thing this is what you want
[self.avSnapper captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error){
CFDictionaryRef exifAttachments = CMGetAttachment( imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
if (exifAttachments){
// Do something with the attachments if you want to.
NSLog(@"attachements: %@", exifAttachments);
}
else
NSLog(@"no attachments");
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
self.vImage.image = image;
}];