<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "QuickLook",
  "identifier" : "/documentation/QuickLook/QLPreviewControllerDataSource/previewController(_:previewItemAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Quick Look"
    ],
    "preciseIdentifier" : "c:objc(pl)QLPreviewControllerDataSource(im)previewController:previewItemAtIndex:"
  },
  "title" : "previewController(_:previewItemAt:)"
}
-->

# previewController(_:previewItemAt:)

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

```
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

The preview item to display. The item must be an `NSURL` object, or a custom object that conforms to the [`QLPreviewItem`](/documentation/QuickLook/QLPreviewItem) protocol.

## Discussion

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

---

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)