O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSSpellChecker — Mac OS X 10.0

Synopsis

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.

image with no caption

@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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required