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

# previewController(_:shouldOpen:for:)

Tells the delegate that the preview controller is trying to open a URL.

```
optional func previewController(_ controller: QLPreviewController, shouldOpen url: URL, for item: any QLPreviewItem) -> Bool
```

## Parameters

`controller`

The Quick Look preview controller that’s asking the delegate to handle a user tapping a URL.

`url`

The URL, from the displayed preview, that the user taps.

`item`

The item displaying in the preview.

## Return Value

A Boolean value indicating whether to open the URL in the `url` parameter.

## Discussion

The system invokes this method when the user taps a URL link in a preview. If you return <doc://com.apple.documentation/documentation/Swift/true>, the Quick Look preview controller invokes the <doc://com.apple.documentation/documentation/UIKit/UIApplication/openURL(_:)> method on the <doc://com.apple.documentation/documentation/UIKit/UIApplication> object, sending it the value of the `url` parameter. If you return <doc://com.apple.documentation/documentation/Swift/false>, the system doesn’t invoke the <doc://com.apple.documentation/documentation/UIKit/UIApplication/openURL(_:)> method.

If you don’t implement this method, it defaults to returning <doc://com.apple.documentation/documentation/Swift/true>.

> Note:
> The system doesn’t call this delegate method for Mac apps built with Mac Catalyst.

---

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)