---
title: "readSelection(from:type:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextview/readselection(from:type:)"
---

# readSelection(from:type:)

Reads data of the given type from the specified pasteboard.

## Declaration

```swift
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

Return Value true if the data was successfully read, false otherwise.

## Discussion

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 method to obtain the range of characters (if any) to be replaced by the new data.

## See Also

### Related Documentation

- [rangeForUserTextChange](appkit/nstextview/rangeforusertextchange.md)

### Managing the pasteboard

- [preferredPasteboardType(from:restrictedToTypesFrom:)](appkit/nstextview/preferredpasteboardtype(from:restrictedtotypesfrom:).md)
- [readSelection(from:)](appkit/nstextview/readselection(from:).md)
- [readablePasteboardTypes](appkit/nstextview/readablepasteboardtypes.md)
- [writablePasteboardTypes](appkit/nstextview/writablepasteboardtypes.md)
- [writeSelection(to:type:)](appkit/nstextview/writeselection(to:type:).md)
- [writeSelection(to:types:)](appkit/nstextview/writeselection(to:types:).md)
- [validRequestor(forSendType:returnType:)](appkit/nstextview/validrequestor(forsendtype:returntype:).md)
