Mac Developer Library

Developer

Foundation Framework Reference NSSpellServerDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSSpellServerDelegate

The NSSpellServerDelegate protocol defines the optional methods implemented by delegates of NSSpellServer objects.

  • Notifies the delegate that the sender has removed the specified word from the user’s list of acceptable words in the specified language.

    Declaration

    Swift

    optional func spellServer(_ sender: NSSpellServer, didForgetWord word: String, inLanguage language: String)

    Objective-C

    - (void)spellServer:(NSSpellServer *)sender didForgetWord:(NSString *)word inLanguage:(NSString *)language

    Parameters

    sender

    The NSSpellServer object that removed the word.

    word

    The word that was removed.

    language

    The language of the removed word.

    Discussion

    If your delegate maintains a similar auxiliary word list, you may wish to edit the list accordingly.

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Notifies the delegate that the sender has added the specified word to the user’s list of acceptable words in the specified language.

    Declaration

    Swift

    optional func spellServer(_ sender: NSSpellServer, didLearnWord word: String, inLanguage language: String)

    Objective-C

    - (void)spellServer:(NSSpellServer *)sender didLearnWord:(NSString *)word inLanguage:(NSString *)language

    Parameters

    sender

    The NSSpellServer object that added the word.

    word

    The word that was added.

    language

    The language of the added word.

    Discussion

    If your delegate maintains a similar auxiliary word list, you may wish to edit the list accordingly.

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • This delegate method returns an array of possible word completions from the spell checker, based on a partially completed string and a given range.

    Declaration

    Swift

    optional func spellServer(_ sender: NSSpellServer, suggestCompletionsForPartialWordRange range: NSRange, inString string: String, language language: String) -> [String]?

    Objective-C

    - (NSArray<NSString *> *)spellServer:(NSSpellServer *)sender suggestCompletionsForPartialWordRange:(NSRange)range inString:(NSString *)string language:(NSString *)language

    Parameters

    sender

    The NSSpellServer object that sent this message.

    range

    The range of the partially completed word.

    string

    The string containing the partial word range.

    language

    The language to use for the completion.

    Return Value

    An array of NSString objects indicating possible completions.

    Availability

    Available in OS X v10.3 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Notifies the spell checker of the users’s response to a correction.

    Declaration

    Swift

    optional func spellServer(_ sender: NSSpellServer, recordResponse response: Int, toCorrection correction: String, forWord word: String, language language: String)

    Objective-C

    - (void)spellServer:(NSSpellServer *)sender recordResponse:(NSUInteger)response toCorrection:(NSString *)correction forWord:(NSString *)word language:(NSString *)language

    Parameters

    sender

    The spell server.

    response

    The user’s response.

    correction

    The corrected word. This should match the original correction.

    word

    The original word. This should match the original correction.

    language

    The language being edited. This should match the original correction.

    Discussion

    When the user accepts, rejects, or edits an autocorrection, the view notifies the NSSpellChecker class of what happened in the client application, and NSSpellChecker then invokes this method, so that it can record that and modify future autocorrection behavior based on what it has learned from the user's actions.

    Availability

    Available in OS X v10.7 and later.