---
title: "providePreview(for:completionHandler:)"
framework: QuickLook UI
role: symbol
role_heading: Instance Method
platforms: [macOS 12.0+]
path: "quicklookui/qlpreviewingcontroller/providepreview(for:completionhandler:)"
---

# providePreview(for:completionHandler:)

Prepares the preview of a file identified within a file preview request.

## Declaration

```swift
optional func providePreview(for request: QLFilePreviewRequest, completionHandler handler: @escaping @Sendable (QLPreviewReply?, (any Error)?) -> Void)
```

```swift
optional func providePreview(for request: QLFilePreviewRequest) async throws -> QLPreviewReply
```

## Parameters

- `request`: The file preview request that identifies the content to preview.
- `handler`: The closure to call with a doc://com.apple.documentation/documentation/quicklook/qlpreviewreply for the system to display as the preview.

## See Also

### Instance Methods

- [preparePreviewOfFile(at:completionHandler:)](quicklookui/qlpreviewingcontroller/preparepreviewoffile(at:completionhandler:).md)
- [preparePreviewOfSearchableItem(identifier:queryString:completionHandler:)](quicklookui/qlpreviewingcontroller/preparepreviewofsearchableitem(identifier:querystring:completionhandler:).md)
