---
title: "tokenRange(at:unit:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nslinguistictagger/tokenrange(at:unit:)"
---

# tokenRange(at:unit:)

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

## Declaration

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

## Parameters

- `charIndex`: The character index to begin examination.
- `unit`: The linguistic unit. For possible values, see doc://com.apple.foundation/documentation/Foundation/NSLinguisticTaggerUnit.

## Return Value

Return Value The range of the substring for the linguistic unit.

## See Also

### Determining the Range of a Unit Token

- [sentenceRange(for:)](foundation/nslinguistictagger/sentencerange(for:).md)
