Instance Method


Finds a tag for a given linguistic unit, for a single scheme, at the specified character position.


@nonobjc func tag(at index: String.Index, unit: NLTokenUnit, scheme: NLTagScheme) -> (NLTag?, Range<String.Index>)



The position of the initial character.


The linguistic unit. For possible values, see NLTokenUnit.


The tag scheme. For possible values, see NLTagScheme.

Return Value

The tag for the requested tag scheme and linguistic unit, or nil. If a tag is returned, this function returns by reference the range of the token to tokenRange.

See Also

Getting Linguistic Tags

func tags(in: Range<String.Index>, unit: NLTokenUnit, scheme: NLTagScheme, options: NLTagger.Options) -> [(NLTag?, Range<String.Index>)]

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software