CocoaDev

Edit AllPages

This article describes how to support spell checking and grammer checking in a custom view. This view supports checking spelling using the Spelling pane and the Edit menu.

There aren’t a lot of examples of how to do this. The best one I could find was WebKit: http://trac.webkit.org/browser/trunk/WebKit/mac/WebCoreSupport/WebEditorClient.mm

–SaileshAgrawal


#import <Cocoa/Cocoa.h>

@interface MyView : NSView { NSString *document; NSRange selection; NSInteger documentTag; NSArray *cachedSpellCheckResults; NSInteger misspellingIndex; NSInteger misspellingCount; } @end

#import “MyView.h”

static BOOL sContinuousSpellCheckingEnabled = YES; static BOOL sGrammarCheckingEnabled = YES;

@interface MyView ()

@property (retain) NSString *document; @property (retain) NSArray *cachedSpellCheckResults;

@end

@implementation MyView

@synthesize document; @synthesize cachedSpellCheckResults;

@end