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

# readSelection(from:)

Reads the text view’s preferred type of data from the specified pasteboard.

```
func readSelection(from pboard: NSPasteboard) -> Bool
```

## Parameters

`pboard`

The pasteboard to read from.

## Return Value

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

## Discussion

This method invokes the [`preferredPasteboardType(from:restrictedToTypesFrom:)`](/documentation/AppKit/NSTextView/preferredPasteboardType(from:restrictedToTypesFrom:)) method to determine the text view’s preferred type of data and then reads the data using the [`readSelection(from:type:)`](/documentation/AppKit/NSTextView/readSelection(from:type:)) method.

You should not need to override this method. You might need to invoke this method if you are implementing a new type of pasteboard to handle services other than copy/paste or dragging.

---

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)