The NSOrthography class describes the linguistic content of a piece of text, typically used for the purposes of spelling and grammar checking.


An NSOrthography instance describes:

  • Which scripts the text contains.

  • A dominant language and possibly other languages for each of these scripts.

  • A dominant script and language for the text as a whole.

Scripts are uniformly described by standard four-letter tags (Latn, Grek, Cyrl, etc.) with the supertags Jpan and Kore typically used for Japanese and Korean text, Hans and Hant for Chinese text; the tag Zyyy is used if a specific script cannot be identified. See Internationalization and Localization Guide for more information on internationalization.

Languages are uniformly described by BCP-47 tags , preferably in canonical form; the tag und is used if a specific language cannot be determined.

Subclassing Notes

Methods to Override

The dominant​Script and language​Map properties are the primitive values that a subclass must implement. The properties are set using the init(dominant​Script:​language​Map:​) or orthography​With​Dominant​Script:​language​Map:​.


Creating Instances of NSOrthography

init(dominant​Script:​ String, language​Map:​ [String :​ [String]])

Creates and returns an orthography instance with the specified dominant script and language map.

Defining the Language Map

var dominant​Script:​ String

The dominant script for the text.

var language​Map:​ [String :​ [String]]

A dictionary that map script tags to arrays of language tags.

Managing Languages and Scripts

func languages(for​Script:​ String)

Returns the list of languages for the specified script.

func dominant​Language(for​Script:​ String)

Returns the dominant language for the specified script.

var all​Languages:​ [String]

Returns an array containing all the languages appearing in the values of the language map.

var all​Scripts:​ [String]

Returns an array containing all the scripts appearing as keys in the language map.

var dominant​Language:​ String

Returns the first language in the list of languages for the dominant script.