---
title: "textRange(from:to:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextinput/textrange(from:to:)"
---

# textRange(from:to:)

Returns the range between two text positions.

## Declaration

```swift
func textRange(from fromPosition: UITextPosition, to toPosition: UITextPosition) -> UITextRange?
```

## Parameters

- `fromPosition`: An object that represents a location in a document.
- `toPosition`: An object that represents another location in a document.

## Return Value

Return Value An object that represents the range between fromPosition and toPosition.

## See Also

### Computing text ranges and text positions

- [position(from:offset:)](uikit/uitextinput/position(from:offset:).md)
- [position(from:in:offset:)](uikit/uitextinput/position(from:in:offset:).md)
- [beginningOfDocument](uikit/uitextinput/beginningofdocument.md)
- [endOfDocument](uikit/uitextinput/endofdocument.md)
