<!--
{
  "availability" : [
    "macOS: 10.0.0 - 12.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "QuickLook",
  "identifier" : "/documentation/QuickLook/QLPreviewRequestSetDataRepresentation(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Quick Look"
    ],
    "preciseIdentifier" : "c:@F@QLPreviewRequestSetDataRepresentation"
  },
  "title" : "QLPreviewRequestSetDataRepresentation(_:_:_:_:)"
}
-->

# QLPreviewRequestSetDataRepresentation(_:_:_:_:)

Sets the preview request to data saved within the document or to dynamically generated data.

```
func QLPreviewRequestSetDataRepresentation(_ preview: QLPreviewRequest!, _ data: CFData!, _ contentTypeUTI: CFString!, _ properties: CFDictionary!)
```

## Parameters

`preview`

The preview request object.

`data`

The data of the preview returned to the client.

`contentTypeUTI`

The UTI specifying the content type of the preview.

`properties`

Additional properties for the preview response. For more on supported keys and values for this dictionary, see `Preview Properties`. If the saved data is HTML, you may specify a special set of properties; see the discussion below for more information.

## Discussion

This function returns preview data to the client. The data is either extracted from a document where the document’s application has saved it, or it’s dynamically generated. How Quick Look handles the data depends upon the value of `contentTypeUTI`. The content data of the preview must be of a native Quick Look type. Currently supported UTIs for these types are: `kUTTypeImage`, `kUTTypePDF`, `kUTTypeHTML`, `kUTTypeXML`, `kUTTypePlainText`, `kUTTypeRTF`, `kUTTypeMovie`, and `kUTTypeAudio`.

If the UTI type is `kUTTypeHTML`, you can have WebKit handle the layout and display of your preview. You must provide the HTML in `data` plus any attachments (for example, Address Book cards, Mail messages, or Omni Outliner documents) in the `properties` dictionary. This dictionary takes [`kQLPreviewPropertyAttachmentsKey`](/documentation/QuickLook/kQLPreviewPropertyAttachmentsKey) as its key and consists of one ore more subdictionaries (one per attachment). Each subdictionary uses an arbitrary string identifier as a key; the attachment should be referenced within the HTML data using the kQLPreviewContentIDScheme URL scheme (“cid”) and the identifier as the URL resource specifier—for example, “cid:the_identifier”. The keys of the subdictionary properties are [`kQLPreviewPropertyMIMETypeKey`](/documentation/QuickLook/kQLPreviewPropertyMIMETypeKey), [`kQLPreviewPropertyTextEncodingNameKey`](/documentation/QuickLook/kQLPreviewPropertyTextEncodingNameKey), and [`kQLPreviewPropertyAttachmentDataKey`](/documentation/QuickLook/kQLPreviewPropertyAttachmentDataKey).

### Special Considerations

Thread-safety: This function should be called in the same thread as the preview request is made in; generally, this is the same thread in which the `GeneratePreviewForURL` callback was invoked.

---

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)