<!--
{
  "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/enumerateTags(in:unit:scheme:options:using:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLinguisticTagger(im)enumerateTagsInRange:unit:scheme:options:usingBlock:"
  },
  "title" : "enumerateTags(in:unit:scheme:options:using:)"
}
-->

# enumerateTags(in:unit:scheme:options:using:)

Enumerates over a given range of the string for a particular unit and calls the specified block for each tag.

```
func enumerateTags(in range: NSRange, unit: NSLinguisticTaggerUnit, scheme: NSLinguisticTagScheme, options: NSLinguisticTagger.Options = [], using block: (NSLinguisticTag?, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void)
```

## Parameters

`range`

The range to analyze.

`unit`

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

`scheme`

The tag scheme. For possible values, see [`NSLinguisticTagScheme`](/documentation/Foundation/NSLinguisticTagScheme).

`options`

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

`block`

The block to apply to ranges of the string.

    The block takes the following arguments:

- tag: The located linguistic tag.
- tokenRange: The range of the linguistic tag.
- stop: A reference to a Boolean value. The block can set the value to <doc://com.apple.documentation/documentation/Swift/true> to stop further processing of the set. The `stop` argument is an out-only argument. You should only ever set this Boolean to <doc://com.apple.documentation/documentation/Swift/true> within the block.

## Discussion

This method’s block is called for all tokens intersecting a given range, supplying tags and ranges. The tagger segments the string into sentences and tokens as necessary, and return those ranges along with a tag for any scheme in its array of tag schemes. For example, if the tag scheme is [`lexicalClass`](/documentation/Foundation/NSLinguisticTagScheme/lexicalClass), the tags specify the part of speech (for word tokens) or the type of whitespace or punctuation (for whitespace or punctuation tokens).  If the tag scheme is [`lemma`](/documentation/Foundation/NSLinguisticTagScheme/lemma), the tags specify the stem form of the word (if known) for each word token.

> Important:
> This method enumerates over the ranges of all tokens that intersect the specified range.

---

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)