---
title: "location(_:offsetBy:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextselectiondatasource/location(_:offsetby:)"
---

# location(_:offsetBy:)

Returns a new location using the location and offset you specify.

## Declaration

```swift
func location(_ location: any NSTextLocation, offsetBy offset: Int) -> (any NSTextLocation)?
```

## Parameters

- `location`: The starting location in the selection.
- `offset`: An offset that describes the extent of the new location.

## Return Value

Return Value A new NSTextLocation, or nil when the inputs don’t produce any legal location, such as when the input is an out of bounds index.

## Discussion

Discussion The offset value can be positive or negative indicating the logical direction.

## See Also

### Finding specific content in the selection

- [lineFragmentRange(for:inContainerAt:)](uikit/nstextselectiondatasource/linefragmentrange(for:incontainerat:).md)
- [offset(from:to:)](uikit/nstextselectiondatasource/offset(from:to:).md)
- [textRange(for:enclosing:)](uikit/nstextselectiondatasource/textrange(for:enclosing:).md)
