<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AVFoundation",
  "identifier" : "/documentation/AVFoundation/AVAssetImageGenerator/generateCGImageAsynchronously(for:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AVFoundation"
    ],
    "preciseIdentifier" : "c:objc(cs)AVAssetImageGenerator(im)generateCGImageAsynchronouslyForTime:completionHandler:"
  },
  "title" : "generateCGImageAsynchronously(for:completionHandler:)"
}
-->

# generateCGImageAsynchronously(for:completionHandler:)

Generates an image asynchronously for a requested time, and returns the result in a callback.

```
func generateCGImageAsynchronously(for requestedTime: CMTime, completionHandler handler: @escaping @Sendable (CGImage?, CMTime, (any Error)?) -> Void)
```

## Parameters

`requestedTime`

A time in the video timeline for which to generate an image. The requested time and actual time at which it generates an image may differ depending on the generator’s time tolerance settings.

`handler`

A callback that the image generator invokes with the result of the request.

## Discussion

Swift clients should use the asynchronous [`image(at:)`](/documentation/AVFoundation/AVAssetImageGenerator/image(at:)) method instead.

## Topics

### Data types

[`AVAssetImageGeneratorCompletionHandler`](/documentation/AVFoundation/AVAssetImageGeneratorCompletionHandler)

A type alias for a closure that provides the result of an image generation request.

[`AVAssetImageGenerator.Result`](/documentation/AVFoundation/AVAssetImageGenerator/Result)

Constants that indicate the result of an image generation request.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)