---
title: "previewController(_:previewItemAt:)"
framework: quicklook
role: symbol
role_heading: Instance Method
path: "quicklook/qlpreviewcontrollerdatasource/previewcontroller(_:previewitemat:)"
---

# previewController(_:previewItemAt:)

Returns the preview item that the controller displays for the specified index.

## Declaration

```swift
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> any QLPreviewItem
```

## Parameters

- `controller`: The Quick Look preview controller that’s requesting a preview item.
- `index`: The index position, within the preview navigation list, of the item to preview.

## Return Value

Return Value The preview item to display. The item must be an NSURL object, or a custom object that conforms to the QLPreviewItem protocol.

## Discussion

Discussion The system invokes this method when the preview controller needs the preview item for a specified index position.

## See Also

### Providing data to a preview controller

- [numberOfPreviewItems(in:)](quicklook/qlpreviewcontrollerdatasource/numberofpreviewitems(in:).md)
