<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NaturalLanguage",
  "identifier" : "/documentation/NaturalLanguage/NLTagger/enumerateTagsInRange:unit:scheme:options:usingBlock:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:objc(cs)NLTagger(im)enumerateTagsInRange:unit:scheme:options:usingBlock:"
  },
  "title" : "enumerateTagsInRange:unit:scheme:options:usingBlock:"
}
-->

# enumerateTagsInRange:unit:scheme:options:usingBlock:

Enumerates a block over the tagger’s string, given a range, token unit, and tag scheme.

```
- (void) enumerateTagsInRange:(NSRange) range unit:(NLTokenUnit) unit scheme:(NLTagScheme) scheme options:(NLTaggerOptions) options usingBlock:(void (^)(NLTag tag, NSRange tokenRange, BOOL *stop)) block;
```

## Parameters

`range`

The range of the string you want the tagger to analyze.

`unit`

The linguistic unit of scale you’re interested in, such as [`NLTokenUnit.word`](/documentation/NaturalLanguage/NLTokenUnit/word), [`NLTokenUnit.sentence`](/documentation/NaturalLanguage/NLTokenUnit/sentence), [`NLTokenUnit.paragraph`](/documentation/NaturalLanguage/NLTokenUnit/paragraph), or [`NLTokenUnit.document`](/documentation/NaturalLanguage/NLTokenUnit/document).

`scheme`

The tag scheme the tagger uses to tag the string, such as [`language`](/documentation/NaturalLanguage/NLTagScheme/language) or [`script`](/documentation/NaturalLanguage/NLTagScheme/script). This scheme determines which types of [`NLTag`](/documentation/NaturalLanguage/NLTag) the method passes to your block. For other tag schemes, see [`NLTagScheme`](/documentation/NaturalLanguage/NLTagScheme).

`options`

The set of linguistic tagger options to use, such as [`omitWhitespace`](/documentation/NaturalLanguage/NLTagger/Options/omitWhitespace). For all available options, see [`NLTagger.Options`](/documentation/NaturalLanguage/NLTagger/Options).

`block`

The block this method uses to iterate over the tagger’s [`string`](/documentation/NaturalLanguage/NLTagger/string) property. The block has the following parameters:

- tag: The tag of the token.
- tokenRange: The range of the token.
- stop: A reference to a Boolean value. The block can set the value to `true` to stop further processing of the set. The `stop` argument is an out-only argument. You should only ever set this Boolean to `true` within the block.

## Discussion

Use this method to iterate your block over the given range of a string. The method divides up the string with the given [`NLTokenUnit`](/documentation/NaturalLanguage/NLTokenUnit) and [`NLTagScheme`](/documentation/NaturalLanguage/NLTagScheme) and then calls your block. For example, use the [`lexicalClass`](/documentation/NaturalLanguage/NLTagScheme/lexicalClass) tag scheme to identify which tokens are parts of speech, types of whitespace, or types of punctuation. Use the [`lemma`](/documentation/NaturalLanguage/NLTagScheme/lemma) tag scheme to identify the stem form of each word token, if known.

> 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)