<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextView/readSelection(from:type:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSTextView(im)readSelectionFromPasteboard:type:"
  },
  "title" : "readSelection(from:type:)"
}
-->

# readSelection(from:type:)

Reads data of the given type from the specified pasteboard.

```
func readSelection(from pboard: NSPasteboard, type: NSPasteboard.PasteboardType) -> Bool
```

## Parameters

`pboard`

The pasteboard to read from.

`type`

The type of data to read.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the data was successfully read, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

## Discussion

The new data is placed at the current insertion point, replacing the current selection if one exists.

You should override this method to read pasteboard types other than the default types. Use the [`rangeForUserTextChange`](/documentation/AppKit/NSTextView/rangeForUserTextChange) method to obtain the range of characters (if any) to be replaced by the new data.

## See Also

[`rangeForUserTextChange`](/documentation/AppKit/NSTextView/rangeForUserTextChange)

The range of characters affected by a method that changes characters (as opposed to attributes).



---

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)