Instance Method


Returns the range of the linguistic unit containing the specified character index.


@nonobjc func tokenRange(at index: String.Index, unit: NLTokenUnit) -> Range<String.Index>



The character index to begin examination.


The linguistic unit. For possible values, see NLTokenUnit.

Return Value

The range of the substring for the linguistic unit.

See Also

Deteriming the Range of a Unit Token

enum NLTokenUnit

Constants representing linguistic units.

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