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

# offset(from:to:)

Returns the offset between the two locations you specify.

## Declaration

```swift
func offset(from: any NSTextLocation, to: any NSTextLocation) -> Int
```

## Parameters

- `from`: The starting location.
- `to`: The ending location.

## See Also

### Finding specific content in the selection

- [location(_:offsetBy:)](uikit/nstextselectiondatasource/location(_:offsetby:).md)
- [lineFragmentRange(for:inContainerAt:)](uikit/nstextselectiondatasource/linefragmentrange(for:incontainerat:).md)
- [textRange(for:enclosing:)](uikit/nstextselectiondatasource/textrange(for:enclosing:).md)
