---
title: "preparePreviewOfSearchableItem(identifier:queryString:completionHandler:)"
framework: QuickLook UI
role: symbol
role_heading: Instance Method
platforms: [macOS 12.0+]
path: "quicklookui/qlpreviewingcontroller/preparepreviewofsearchableitem(identifier:querystring:completionhandler:)"
---

# preparePreviewOfSearchableItem(identifier:queryString:completionHandler:)

Prepares the preview for a file by using the data from Spotlight’s searchable item.

## Declaration

```swift
optional func preparePreviewOfSearchableItem(identifier: String, queryString: String?, completionHandler handler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
optional func preparePreviewOfSearchableItem(identifier: String, queryString: String?) async throws
```

## Parameters

- `identifier`: The identifier of the searchable item.
- `queryString`: A search string to associate with the searchable item.
- `handler`: A completion handler that notifies the platform that a preview is available. The operating system shows a loading spinner, so call the handler as soon as possible. You can call the completion handler asynchronously after returning from the callback.

## Discussion

Discussion The operating system calls this method only once from the main thread before it presents the previewing controller. To avoid blocking the main thread, don’t perform long-running or resource-intensive work.

## See Also

### Instance Methods

- [preparePreviewOfFile(at:completionHandler:)](quicklookui/qlpreviewingcontroller/preparepreviewoffile(at:completionhandler:).md)
- [providePreview(for:completionHandler:)](quicklookui/qlpreviewingcontroller/providepreview(for:completionhandler:).md)
