NSSpellChecker

NSSpellChecker Mac OS X 10.0

This class provides an interface to Cocoa's spellchecking service. A shared instance of NSSpellChecker is returned using the class method sharedSpellChecker. To check the spelling of a length of text, invoke the method checkSpellingOfString:startingAt:, which takes the string to check and the offset in the string where the spellcheck should commence. This method will return an NSRange indicating the location of the first misspelled word. Clients then update the contents of the spellchecking panel to notify the user of the discovery of the misspelled word using the method updateSpellingPanelWithMisspelledWord:; passing an empty string here will cause the spellchecking process to terminate. Support for spellchecking services is built into the Cocoa text handling classes. If you wish to implement support for spellchecking into a class of your own, then you must implement the methods declared in the NSChangeSpelling and NSIgnoreMisspelledWords protocols; see the protocol descriptions in Chapter 16 for more information.

figs/cocn_1590.gif

@interface NSSpellChecker : NSObject
 // Accessor Methods
   - (void)setIgnoredWords:(NSArray *)words inSpellDocumentWithTag:(int)tag;
   - (void)setWordFieldStringValue:(NSString *)aString;
   - (BOOL)setLanguage:(NSString *)language;
   - (NSString *)language;
   - (void)setAccessoryView:(NSView *)aView;
   - (NSView *)accessoryView;
 // Class Methods
   + (NSSpellChecker *)sharedSpellChecker;
   + (BOOL)sharedSpellCheckerExists;
   + (int)uniqueSpellDocumentTag;
 // Instance Methods
   - (NSRange)checkSpellingOfString:(NSString *)stringToCheck startingAt:(int)startingOffset;
   - (int)countWordsInString:(NSString *)stringToCount language:(NSString *)language;
   - (NSRange)checkSpellingOfString:(NSString *)stringToCheck startingAt:(int)startingOffset
        language:(NSString *)language wrap:(BOOL)wrapFlag inSpellDocumentWithTag:(int)tag
        wordCount:(int *)wordCount;
   - (void)closeSpellDocumentWithTag:(int)tag;
   - (NSArray *)guessesForWord:(NSString *)word;
   - (void)ignoreWord:(NSString *)wordToIgnore inSpellDocumentWithTag:(int)tag;
   - (NSArray *)ignoredWordsInSpellDocumentWithTag:(int)tag;
   - (NSPanel *)spellingPanel;
   - (void)updateSpellingPanelWithMisspelledWord:(NSString *)word;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes