Instance Method


Initiates a still image capture and returns immediately.


func captureStillImageAsynchronously(from connection: AVCaptureConnection, completionHandler handler: @escaping (CMSampleBuffer?, Error?) -> Void)



The connection from which to capture the image.


A block to invoke after the image has been captured. The block parameters are as follows:


The data that was captured.

The buffer attachments may contain metadata appropriate to the image data format. For example, a buffer containing JPEG data may carry a kCGImagePropertyExifDictionary as an attachment. See ImageIO/CGImageProperties.h for a list of keys and value types.


If the request could not be completed, an NSError object that describes the problem; otherwise nil.


This method returns immediately after it is invoked, later calling the provided completion handler block when image data is ready. If the request could not be completed, the error parameter will contain an NSError object describing the failure.

You should not assume that the completion handler will be called on a specific thread.

See Also

Capturing an Image

var isCapturingStillImage: Bool

Indicates whether a still image is being captured.


Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software