Class

NSSpell​Checker

Provides an interface to the Cocoa spell-checking service.

Overview

To handle all its spell checking, an app needs only one instance of NSSpell​Checker, known as the spell checker. Using the spell checker you manage the Spelling panel, in which the user can specify decisions about words that are suspect. The spell checker also offers the ability to provide word completions to augment the text completion system.

Symbols

Getting the Spell Checker

class func shared()

Returns the NSSpellChecker (one per application).

class func shared​Spell​Checker​Exists()

Returns whether the application’s NSSpellChecker has already been created.

Configuring Spell Checkers Languages

var available​Languages:​ [String]

Provides a list of all available languages.

var user​Preferred​Languages:​ [String]

Provides a subset of the available languages to be used for spell checking.

var automatically​Identifies​Languages:​ Bool

Sets whether the spell checker will automatically identify languages.

func language()

Returns the current language used in spell checking.

func set​Language(String)

Returns whether the specified language is in the Spelling pop-up list.

Managing Panels

var spelling​Panel:​ NSPanel

Returns the spell checker’s panel.

var substitutions​Panel:​ NSPanel

Returns the substitutions panel.

func update​Spelling​Panel(with​Grammar​String:​ String, detail:​ [String :​ Any])

Specifies a grammar-analysis detail to highlight in the Spelling panel.

func update​Panels()

Updates the available panels to account for user changes.

var accessory​View:​ NSView?

Makes an view an accessory of the Spelling panel by making it a subview of the panel’s content view.

Checking Strings for Spelling and Grammar

func count​Words(in:​ String, language:​ String?)

Returns the number of words in the specified string.

func check​Spelling(of:​ String, starting​At:​ Int)

Starts the search for a misspelled word in string​To​Check starting at starting​Offset within the string object.

Managing the Spell-Checking Process

class func unique​Spell​Document​Tag()

Returns a guaranteed unique tag to use as the spell-document tag for a document.

func close​Spell​Document(with​Tag:​ Int)

Notifies the receiver that the user has finished with the tagged document.

func ignore​Word(String, in​Spell​Document​With​Tag:​ Int)

Instructs the spell checker to ignore all future occurrences of word​To​Ignore in the document identified by tag.

func ignored​Words(in​Spell​Document​With​Tag:​ Int)

Returns the array of ignored words for a document identified by tag.

func set​Ignored​Words([String], in​Spell​Document​With​Tag:​ Int)

Initializes the ignored-words document (a dictionary identified by tag with some​Words), an array of words to ignore.

func set​Word​Field​String​Value(String)

Sets the string that appears in the misspelled word field, using the string object a​String.

func update​Spelling​Panel(with​Misspelled​Word:​ String)

Causes the spell checker to update the Spelling panel’s misspelled-word field to reflect word.

func completions(for​Partial​Word​Range:​ NSRange, in:​ String, language:​ String?, in​Spell​Document​With​Tag:​ Int)

Provides a list of complete words that the user might be trying to type based on a partial word in a given string.

func has​Learned​Word(String)

Indicates whether the spell checker has learned a given word.

func unlearn​Word(String)

Tells the spell checker to unlearn a given word.

func learn​Word(String)

Adds the word to the spell checker dictionary.

func user​Quotes​Array(for​Language:​ String)

Returns the default values for quote replacement.

var user​Replacements​Dictionary:​ [String :​ String]

Returns the dictionary used when replacing words.

Data Detector Interaction

func menu(for:​ NSText​Checking​Result, string:​ String, options:​ [String :​ Any]? = nil, at​Location:​ NSPoint, in:​ NSView)

Provides a menu containing contextual menu items suitable for certain kinds of detected results.

Automatic Text Replacement

class func is​Automatic​Text​Replacement​Enabled()

Returns whether automatic spelling replacement is enabled.

Notifications

static let NSSpell​Checker​Did​Change​Automatic​Spelling​Correction:​ NSNotification.Name

This notification is posted when the spell checker did change text using automatic spell checking correction. The are posted to the application’s default notification center.

static let NSSpell​Checker​Did​Change​Automatic​Text​Replacement:​ NSNotification.Name

Posted when the spell checker changed text using automatic text replacement. This notification is posted to the app’s default notification center.

Relationships

Inherits From