---
title: "enumerateTokens(in:using:)"
framework: naturallanguage
role: symbol
role_heading: Instance Method
path: "naturallanguage/nltokenizer/enumeratetokens(in:using:)"
---

# enumerateTokens(in:using:)

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

## Declaration

```swift
@nonobjc func enumerateTokens(in range: Range<String.Index>, using block: (Range<String.Index>, NLTokenizer.Attributes) -> Bool)
```

## Parameters

- `range`: The range of the string to tokenize.
- `block`: The closure to call after each token; return false if processing should stop.

## See Also

### Enumerating the tokens

- [tokens(for:)](naturallanguage/nltokenizer/tokens(for:).md)
- [tokenRange(at:)](naturallanguage/nltokenizer/tokenrange(at:).md)
- [tokenRange(for:)](naturallanguage/nltokenizer/tokenrange(for:).md)
