<!--
{
  "availability" : [
    "iOS: 11.0.0 - 27.0.0",
    "iPadOS: 11.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.13.0 - 27.0.0",
    "tvOS: 11.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 4.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSLinguisticTagger/tokenRange(at:unit:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLinguisticTagger(im)tokenRangeAtIndex:unit:"
  },
  "title" : "tokenRange(at:unit:)"
}
-->

# tokenRange(at:unit:)

Returns the range of the linguistic unit containing the specified character index.

```
func tokenRange(at charIndex: Int, unit: NSLinguisticTaggerUnit) -> NSRange
```

## Parameters

`charIndex`

The character index to begin examination.

`unit`

The linguistic unit. For possible values, see [`NSLinguisticTaggerUnit`](/documentation/Foundation/NSLinguisticTaggerUnit).

## Return Value

The range of the substring for the linguistic unit.

## Discussion

---

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)