---
title: "tags(for:range:unit:scheme:options:orthography:tokenRanges:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nslinguistictagger/tags(for:range:unit:scheme:options:orthography:tokenranges:)"
---

# tags(for:range:unit:scheme:options:orthography:tokenRanges:)

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

## Declaration

```swift
class func tags(for string: String, range: NSRange, unit: NSLinguisticTaggerUnit, scheme: NSLinguisticTagScheme, options: NSLinguisticTagger.Options = [], orthography: NSOrthography?, tokenRanges: AutoreleasingUnsafeMutablePointer<NSArray?>?) -> [NSLinguisticTag]
```

## Parameters

- `string`: The range from which to return tags.
- `range`: The linguistic unit. See doc://com.apple.foundation/documentation/Foundation/NSLinguisticTaggerUnit for possible values.
- `unit`: The tag scheme. See doc://com.apple.foundation/documentation/Foundation/NSLinguisticTagScheme for possible values.
- `scheme`: The linguistic tagger options to use. See doc://com.apple.foundation/documentation/Foundation/NSLinguisticTagger/Options for possible values.
- `options`: Returns by reference an array of token ranges.

## Return Value

Return Value An array of the tags in the requested range.

## Discussion

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 initializing a linguistic tagger, setting the string property, and calling the tags(in:unit:scheme:options:tokenRanges:) method. If you analyze the same string more than once, you should create a linguistic tagger object instead of calling this method.

## See Also

### Getting Linguistic Tags

- [tag(at:unit:scheme:tokenRange:)](foundation/nslinguistictagger/tag(at:unit:scheme:tokenrange:).md)
- [tag(at:scheme:tokenRange:sentenceRange:)](foundation/nslinguistictagger/tag(at:scheme:tokenrange:sentencerange:).md)
- [tag(for:at:unit:scheme:orthography:tokenRange:)](foundation/nslinguistictagger/tag(for:at:unit:scheme:orthography:tokenrange:).md)
- [tags(in:unit:scheme:options:tokenRanges:)](foundation/nslinguistictagger/tags(in:unit:scheme:options:tokenranges:).md)
- [tags(in:scheme:options:tokenRanges:)](foundation/nslinguistictagger/tags(in:scheme:options:tokenranges:).md)
