---
title: selectedRange()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nstextinputclient/selectedrange()
---

# selectedRange()

Returns the range of selected text.

## Declaration

```swift
func selectedRange() -> NSRange
```

## Return Value

Return Value The range of selected text or {NSNotFound, 0} if there is no selection.

## Discussion

Discussion The returned range measures from the start of the receiver’s text storage, that is, from 0 to the document length.

## See Also

### Handling marked text

- [hasMarkedText()](appkit/nstextinputclient/hasmarkedtext().md)
- [markedRange()](appkit/nstextinputclient/markedrange().md)
- [setMarkedText(_:selectedRange:replacementRange:)](appkit/nstextinputclient/setmarkedtext(_:selectedrange:replacementrange:).md)
- [unmarkText()](appkit/nstextinputclient/unmarktext().md)
- [validAttributesForMarkedText()](appkit/nstextinputclient/validattributesformarkedtext().md)
