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

# location(_:offsetBy:)

Returns a new location from location with offset you provide.

## Declaration

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

## Parameters

- `location`: An doc://com.apple.appkit/documentation/AppKit/NSTextLocation in the text element.
- `offset`: An offset of the number of characters to or from location.

## Return Value

Return Value An new NSTextLocation, or nil of the offset exceeds the bounds of the text.

## See Also

### Accessing and updating the text

- [enumerateTextElements(from:options:using:)](appkit/nstextelementprovider/enumeratetextelements(from:options:using:).md)
- [NSTextLayoutFragment.EnumerationOptions](appkit/nstextlayoutfragment/enumerationoptions.md)
- [replaceContents(in:with:)](appkit/nstextelementprovider/replacecontents(in:with:).md)
