---
title: "textSelection(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextselection/textselection(_:)"
---

# textSelection(_:)

Creates a subselection of the current text selection with the ranges you specify.

## Declaration

```swift
func textSelection(_ textRanges: [NSTextRange]) -> NSTextSelection
```

## Parameters

- `textRanges`: An array of text ranges.

## Return Value

Return Value A new NSTextSelection.
