<!--
{
  "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/tag(for:at:unit:scheme:orthography:tokenRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLinguisticTagger(cm)tagForString:atIndex:unit:scheme:orthography:tokenRange:"
  },
  "title" : "tag(for:at:unit:scheme:orthography:tokenRange:)"
}
-->

# tag(for:at:unit:scheme:orthography:tokenRange:)

Returns a tag for a single scheme, for a given linguistic unit, at the specified character position in a string.

```
class func tag(for string: String, at charIndex: Int, unit: NSLinguisticTaggerUnit, scheme: NSLinguisticTagScheme, orthography: NSOrthography?, tokenRange: NSRangePointer?) -> NSLinguisticTag?
```

## Parameters

`string`

The position of the initial character.

`charIndex`

The linguistic unit. See [`NSLinguisticTaggerUnit`](/documentation/Foundation/NSLinguisticTaggerUnit) for possible values.

`unit`

The tag scheme. See [`NSLinguisticTagScheme`](/documentation/Foundation/NSLinguisticTagScheme) for possible values.

`scheme`

A pointer to the token range.

## Return Value

Returns the tag for the requested tag scheme and linguistic unit, or `nil`. If a tag is returned, this function returns by reference the range of the token to `tokenRange`.

## Discussion

This is a convenience method for initializing a linguistic tagger, setting the [`string`](/documentation/Foundation/NSLinguisticTagger/string) property, and calling the [`tag(for:at:unit:scheme:orthography:tokenRange:)`](/documentation/Foundation/NSLinguisticTagger/tag(for:at:unit:scheme:orthography:tokenRange:)) method. If you analyze the same string more than once, you should create a linguistic tagger object instead of calling this method.

---

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)