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

# offset(from:to:)

Returns the number of UTF-16 characters between one text position and another text position.

## Declaration

```swift
func offset(from: UITextPosition, to toPosition: UITextPosition) -> Int
```

## Parameters

- `from`: A custom object that represents a location within a document.
- `toPosition`: A custom object that represents another location within document.

## Return Value

Return Value The number of UTF-16 characters between fromPosition and toPosition.

## See Also

### Evaluating text positions

- [compare(_:to:)](uikit/uitextinput/compare(_:to:).md)
