Next Page > Hide TOC

NSSpellServer Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSSpellServer.h

Overview

The NSSpellServer class gives you a way to make your application’s spell checker available as a spelling service available to any application.

A service provider is an application that declares its availability in a standard way, so that any other applications that wish to use it can do so. If you build a spelling checker that makes use of the NSSpellServer class and list it as an available service, then users of any application that makes use of NSSpellChecker or includes a Services menu will see your spelling checker as one of the available dictionaries.

Tasks

Configuring Spelling Servers

Providing Spelling Services

Managing the Spell-Checking Process

Instance Methods

delegate

Returns the receiver’s delegate.

- (id)delegate

Availability
See Also
Declared In
NSSpellServer.h

isWordInUserDictionaries:caseSensitive:

Indicates whether a given word is in the user’s list of learned words or the document’s list of words to ignore.

- (BOOL)isWordInUserDictionaries:(NSString *)word caseSensitive:(BOOL)caseSensitive

Parameters
word

The word to compare with those in the user dictionaries.

caseSensitive

Specifies whether the comparison is case sensitive.

Return Value

A Boolean value indicating whether the word is in the user dictionaries. If YES, the word is acceptable to the user.

Availability
Declared In
NSSpellServer.h

registerLanguage:byVendor:

Notifies the receiver of a language your spelling checker can check.

- (BOOL)registerLanguage:(NSString *)language byVendor:(NSString *)vendor

Parameters
language

A string specifying the English name of a language on Apple’s list of languages.

vendor

A string that identifies the vendor (to distinguish your spelling checker from those that others may offer for the same language).

Return Value

Returns YES if the language is registered, NO if for some reason it can’t be registered.

Discussion

If your spelling checker supports more than one language, it should invoke this method once for each language. Registering a language-vendor combination causes it to appear in the Spelling panel’s pop-up menu of spelling checkers.

Availability
Declared In
NSSpellServer.h

run

Causes the receiver to start listening for spell-checking requests.

- (void)run

Discussion

This method starts a loop that never returns; you need to set the NSSpellServer object’s delegate before sending this message.

Availability
See Also
Declared In
NSSpellServer.h

setDelegate:

Assigns the specified delegate to the receiver.

- (void)setDelegate:(id)anObject

Parameters
anObject

The delegate assigned to the receiver.

Discussion

Because the delegate is where the real work is done, this step is essential before telling the NSSpellServer object to run.

Availability
See Also
Declared In
NSSpellServer.h

Delegate Methods

spellServer:checkGrammarInString:language:details:

Gives the delegate the opportunity to customize the grammatical analysis of a given string.

- (NSRange)spellServer:(NSSpellServer *)sender checkGrammarInString:(NSString *)string language:(NSString *)language details:(NSArray **)outDetails

Parameters
sender

Spell server satisfying a grammatical analysis request.

string

String to analyze.

language

Language use in string. When nil, the language selected in the Spelling panel is used.

outDetails

On output, dictionaries describing grammar-analysis details within the flagged grammatical unit. See the NSSpellServer class for information about these dictionaries.

Return Value

Location of the first flagged grammatical unit within string.

Availability
Declared In
NSSpellServer.h

spellServer:didForgetWord:inLanguage:

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

- (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
Declared In
NSSpellServer.h

spellServer:didLearnWord:inLanguage:

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

- (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
Declared In
NSSpellServer.h

spellServer:findMisspelledWordInString:language:wordCount:countOnly:

Asks the delegate to search for a misspelled word in a given string, using the specified language, and marking the first misspelled word found by returning its range within the string.

- (NSRange)spellServer:(NSSpellServer *)sender findMisspelledWordInString:(NSString *)stringToCheck language:(NSString *)language wordCount:(int32_t *)wordCount countOnly:(BOOL)countOnly

Parameters
sender

The NSSpellServer object that sent this message.

stringToCheck

The string to search for the misspelled word.

language

The language to use for the search.

wordCount

On output, returns by reference the number of words from the beginning of the string object until the misspelled word (or the end of string).

countOnly

If YES, the method only counts the words in the string object and does not spell checking.

Return Value

The range of the misspelled word within the given string.

Discussion

Send isWordInUserDictionaries:caseSensitive: to the spelling server to determine if the word exists in the user’s language dictionaries.

Availability
Declared In
NSSpellServer.h

spellServer:suggestCompletionsForPartialWordRange:inString:language:

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

- (NSArray *)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.

Discussion

See completionsForPartialWordRange:inString:language:inSpellDocumentWithTag: in NSSpellChecker for more information.

Availability
Declared In
NSSpellServer.h

spellServer:suggestGuessesForWord:inLanguage:

Gives the delegate the opportunity to suggest guesses to the sender for the correct spelling of the given misspelled word in the specified language.

- (NSArray *)spellServer:(NSSpellServer *)sender suggestGuessesForWord:(NSString *)word inLanguage:(NSString *)language

Parameters
sender

The NSSpellServer object that sent this message.

word

The misspelled word.

language

The language to use for the guesses.

Return Value

An array of NSString objects indicating possible correct spellings.

Availability
Declared In
NSSpellServer.h

Constants

Grammatical-Analysis Details

These constants are use as the keys in the outDetails dictionaries returned by spellServer:checkGrammarInString:language:details: and NSSpellChecker -checkGrammarOfString:startingAt:language:wrap:inSpellingDocumentWithTag:details:.

FOUNDATION_EXPORT NSString *const NSGrammarRange;
FOUNDATION_EXPORT NSString *const NSGrammarUserDescription;
FOUNDATION_EXPORT NSString *const NSGrammarCorrections;

Constants
NSGrammarRange

NSGrammarUserDescription

NSGrammarCorrections

Declared In
NSSpellServer.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-27)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.