Conforms to | |
Framework | /System/Library/Frameworks/Foundation.framework |
Availability | Available in Mac OS X v10.6 and later. |
Companion guide | |
Declared in | NSSpellServer.h |
The NSSpellServerDelegate
protocol defines the optional methods implemented by delegates of NSSpellServer
objects.
– spellServer:checkString:offset:types:options:orthography:wordCount:
– spellServer:suggestGuessesForWord:inLanguage:
– spellServer:checkGrammarInString:language:details:
– spellServer:findMisspelledWordInString:language:wordCount:countOnly:
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
Spell server satisfying a grammatical analysis request.
String to analyze.
Language use in string. When nil
, the language selected in the Spelling panel is used.
On output, dictionaries describing grammar-analysis details within the flagged grammatical unit. See the NSSpellServer
class for information about these dictionaries.
Location of the first flagged grammatical unit within string.
NSSpellServer.h
Gives the delegate the opportunity to analyze both the spelling and grammar simultaneously, which is more efficient.
- (NSArray *)spellServer:(NSSpellServer *)sender checkString:(NSString *)stringToCheck offset:(NSUInteger)offset types:(NSTextCheckingTypes)checkingTypes options:(NSDictionary *)options orthography:(NSOrthography *)orthography wordCount:(NSInteger *)wordCount
Spell server making the analysis request.
String to analyze.
The offset in the string.
The text checking types to perform.
A dictionary defining the actions to be taken while checking this string. See Constants in NSSpellChecker
for the possible keys.
The identified orthography of stringToCheck. See NSOrthography
for more information.
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).
An array of NSTextCheckingResult instances of the spelling, grammar, or correction types, depending on the checkingTypes requested.
This method is optional, but if implemented it will be called during the course of unified text checking via the NSSpellChecker
checkSpellingOfString:startingAt:
and requestCheckingOfString:range:types:options:inSpellDocumentWithTag:completionHandler:
methods. This allows spelling and grammar checking to be performed simultaneously, which can be significantly more efficient, and allows the delegate to return autocorrection results as well.
If this method is not implemented, then unified text checking will call the separate spelling and grammar checking methods instead.
This method may be called repeatedly with strings representing different subranges of the string that was originally requested to be checked; the offset argument represents the offset of the portion passed in to this method within that original string, and should be added to the origin of the range in any NSTextCheckingResult
returned.
NSSpellServer.h
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
The NSSpellServer
object that removed the word.
The word that was removed.
The language of the removed word.
If your delegate maintains a similar auxiliary word list, you may wish to edit the list accordingly.
NSSpellServer.h
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
The NSSpellServer
object that added the word.
The word that was added.
The language of the added word.
If your delegate maintains a similar auxiliary word list, you may wish to edit the list accordingly.
NSSpellServer.h
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:(NSInteger *)wordCount countOnly:(BOOL)countOnly
The NSSpellServer
object that sent this message.
The string to search for the misspelled word.
The language to use for the search.
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).
If YES
, the method only counts the words in the string object and does not spell checking.
The range of the misspelled word within the given string.
Send isWordInUserDictionaries:caseSensitive:
to the spelling server to determine if the word exists in the user’s language dictionaries.
NSSpellServer.h
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
The NSSpellServer
object that sent this message.
The range of the partially completed word.
The string containing the partial word range.
The language to use for the completion.
An array of NSString
objects indicating possible completions.
NSSpellServer.h
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
The NSSpellServer
object that sent this message.
The misspelled word.
The language to use for the guesses.
An array of NSString
objects indicating possible correct spellings.
NSSpellServer.h
Last updated: 2009-05-19