---
title: "enumerateTags(in:scheme:options:using:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nslinguistictagger/enumeratetags(in:scheme:options:using:)"
---

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

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

## Declaration

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

## Parameters

- `range`: The range to analyze.
- `tagScheme`: The tag scheme. For possible values, see doc://com.apple.foundation/documentation/Foundation/NSLinguisticTagScheme.
- `opts`: The linguistic tagger options to use. See doc://com.apple.foundation/documentation/Foundation/NSLinguisticTagger/Options for possible values.
- `block`: The block to apply to ranges of the string. The block takes the following arguments:

## Discussion

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, 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, 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. This is a convenience method for calling the enumerateTags(in:unit:scheme:options:using:) method, passing NSLinguisticTaggerUnit.word as the linguistic unit.

## See Also

### Enumerating Linguistic Tags

- [Identifying Parts of Speech](foundation/identifying-parts-of-speech.md)
- [Identifying People, Places, and Organizations](foundation/identifying-people-places-and-organizations.md)
- [enumerateTags(in:unit:scheme:options:using:)](foundation/nslinguistictagger/enumeratetags(in:unit:scheme:options:using:).md)
- [enumerateTags(for:range:unit:scheme:options:orthography:using:)](foundation/nslinguistictagger/enumeratetags(for:range:unit:scheme:options:orthography:using:).md)
- [NSLinguisticTagger.Options](foundation/nslinguistictagger/options.md)
