<!--
{
  "availability" : [
    "macOS: 15.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextPreview/init(snapshotImage:presentationFrame:candidateRects:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextPreview(im)initWithSnapshotImage:presentationFrame:candidateRects:"
  },
  "title" : "init(snapshotImage:presentationFrame:candidateRects:)"
}
-->

# init(snapshotImage:presentationFrame:candidateRects:)

Creates a text preview using the specified image and rectangles that indicate
the portions of text to highlight.

```
init(snapshotImage: CGImage, presentationFrame: NSRect, candidateRects: [NSValue])
```

## Parameters

`snapshotImage`

An image that contains the requested text from your view.
Create the image using a transparent background and the current rendering
attributes for your text.

`presentationFrame`

A rectangle in the coordinate space of your text view.
The system uses this rectangle to place your image precisely over your
view’s actual text. Set its size to the size of your snapshot image, and
set its origin to the point that allows the system to place your image
directly over the text.

`candidateRects`

An array of <doc://com.apple.documentation/documentation/Foundation/NSValue>
objects, each of which contains an <doc://com.apple.documentation/documentation/Foundation/NSRect>
in the coordinate space of your text view. Each rectangle contains a
bounding rectangle for text that is part of the preview. When applying
visual effects, the system adds highlights only to the text in the specified rectangles.

---

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)