<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextElementProvider/location(_:offsetBy:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextElementProvider(im)locationFromLocation:withOffset:"
  },
  "title" : "location(_:offsetBy:)"
}
-->

# location(_:offsetBy:)

Returns a new location from location with offset you provide.

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

## Parameters

`location`

An [`NSTextLocation`](/documentation/AppKit/NSTextLocation) in the text element.

`offset`

An offset of the number of characters to or from `location`.

## Return Value

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)