iOS Developer Library

Developer

Foundation Framework Reference NSOrthography Class Reference

Options
Deployment Target:

On This Page
Language:

NSOrthography

Inherits From


Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in iOS 4.0 and later

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 dominantScript and languageMap properties are the primitive values that a subclass must implement. The properties are set using the initWithDominantScript:languageMap: or orthographyWithDominantScript:languageMap:.

  • The dominant script for the text. (read-only)

    Declaration

    Swift

    var dominantScript: String { get }

    Objective-C

    @property(readonly, copy) NSString *dominantScript

    Discussion

    The dominant script should be a script tag, such as Latn, Cyrl, etc.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later

    See Also

    languageMap

  • A dictionary that map script tags to arrays of language tags. (read-only)

    Declaration

    Swift

    var languageMap: [NSObject : AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSDictionary *languageMap

    Discussion

    The dictionary’s keys are script tags (such as Latn, Cyrl, and so forth) and whose values are arrays of language tags (such as en, fr, de, etc.)

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later

    See Also

    dominantScript

  • Returns the list of languages for the specified script.

    Declaration

    Swift

    func languagesForScript(_ script: String) -> [AnyObject]?

    Objective-C

    - (NSArray *)languagesForScript:(NSString *)script

    Parameters

    script

    The script.

    Return Value

    An array of strings containing the languages.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later

  • Returns the dominant language for the specified script.

    Declaration

    Swift

    func dominantLanguageForScript(_ script: String) -> String

    Objective-C

    - (NSString *)dominantLanguageForScript:(NSString *)script

    Parameters

    script

    The script.

    Return Value

    A string containing the dominant language

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later

  • Returns an array containing all the languages appearing in the values of the language map. (read-only)

    Declaration

    Swift

    var allLanguages: [AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSArray *allLanguages

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later

  • Returns an array containing all the scripts appearing as keys in the language map. (read-only)

    Declaration

    Swift

    var allScripts: [AnyObject] { get }

    Objective-C

    @property(readonly, copy) NSArray *allScripts

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later

  • Returns the first language in the list of languages for the dominant script. (read-only)

    Declaration

    Swift

    var dominantLanguage: String { get }

    Objective-C

    @property(readonly, copy) NSString *dominantLanguage

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 4.0 and later