<!--
{
  "availability" : [
    "iOS: 5.0.0 - 27.0.0",
    "iPadOS: 5.0.0 - 27.0.0",
    "macCatalyst: 13.1.0 - 27.0.0",
    "macOS: 10.7.0 - 27.0.0",
    "tvOS: 9.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 2.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSLinguisticTagger/tags(in:scheme:options:tokenRanges:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLinguisticTagger(im)tagsInRange:scheme:options:tokenRanges:"
  },
  "title" : "tags(in:scheme:options:tokenRanges:)"
}
-->

# tags(in:scheme:options:tokenRanges:)

Returns an array of linguistic tags and token ranges for a given string range.

```
func tags(in range: NSRange, scheme tagScheme: String, options opts: NSLinguisticTagger.Options = [], tokenRanges: AutoreleasingUnsafeMutablePointer<NSArray?>?) -> [String]
```

## Parameters

`range`

The range from which to return tags.

`tagScheme`

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

`opts`

The linguistic tagger options to use. See [`NSLinguisticTagger.Options`](/documentation/Foundation/NSLinguisticTagger/Options) for possible values.

`tokenRanges`

Returns by reference an array of token ranges.

## Return Value

An array of the tags in the requested range.

## Discussion

When the returned array contains an entry that doesn’t have a corresponding tag scheme, that entry is an empty string (`""`).

This is a convenience method for calling [`tags(in:unit:scheme:options:tokenRanges:)`](/documentation/Foundation/NSLinguisticTagger/tags(in:unit:scheme:options:tokenRanges:)) and passing [`NSLinguisticTaggerUnit.word`](/documentation/Foundation/NSLinguisticTaggerUnit/word) as the linguistic unit.

---

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)