ftp.nice.ch/peanuts/GeneralData/Documents/openstep/OpenStepSpec_rtf.tar.gz#/OpenStepSpec_rtf/ApplicationKit/Classes/NSSpellChecker.rtf

This is NSSpellChecker.rtf in view mode; [Download] [Up]

paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc.  All Rights Reserved.

s4 li100 fi0 ri1007 ql f0 b fs36 fs100 
fs36 NSSpellChecker 
pard s11 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 
fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSObject
fs20 
fs28 s6 f0 b fs24 Conforms To:tab b0 fs28 f1 NSObject (NSObject)
fs20 
fs28 s7 f0 b fs24 Declared In:tab b0 fs28 f1 AppKit/NSSpellChecker.h 
fs20 
fs28 pard s16 li100 fi0 ri1007 ql f0 b fs28 fs20 
fs28 Class Description
fs14 
fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 
fs28 The NSSpellChecker class gives any application an interface to the OpenStep spell-checking service. To handle all its spell checking, an application needs only one instance of NSSpellChecker. It provides a panel in which the user can specify decisions about words that are suspect. To check the spelling of a piece of text, the application:
fs16 
fs28 pard s3 li1231 fi-376 ri1007 ql tx1231 tx2872 tx3250 'b7tab Includes in its user interface a menu item (or a button or command) by which the user will request spell checking.
fs16 
fs28 'b7tab Makes the text available by way of an NSString object.
fs16 
fs28 'b7tab Creates an instance of the NSSpellChecker class and sends it a b checkSpellingOfString:startingAt:b0  message.
fs16 
fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 For example, you might use the following statement to create an NSSpellChecker:
fs16 
fs28 pard s5 li1231 fi0 ri1007 ql f2 fs20 range = [[NSSpellChecker sharedSpellChecker] checkSpellingOfString:aString startingAt:0];
pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 fs28 fs16 
fs28 The b checkSpellingOfString:startingAt:b0  method checks the spelling of the words in the specified string beginning at the specified offset (this example uses 0 to start at the beginning of the string) until it finds a word that is misspelled. Then it returns an NSRange to indicate the location of the misspelled word.
fs16 
fs28 In a graphical application, whenever a misspelled word is found, you'27ll probably want to highlight the word in the document, using the NSRange that b checkSpellingOfString:startingAt:b0  returned to determine the text to highlight. Then you should show the misspelled word in the Spelling panel'27s misspelled-word field by calling b updateSpellingPanelWithMisspelledWord:b0 . If b checkSpellingOfString:startingAt:b0  does not find a misspelled word, you should call b updateSpellingPanelWithMisspelledWord:b0  with the empty string. This causes the system to beep, letting the user know that the spell check is complete and no misspelled words were found. None of these steps is required, but if you do one, you should do them all.
fs16 
fs28 The object that provides the string being checked should adopt the following protocols:
fs16 
fs28 pard s18 li4509 fi-3655 ri1007 ql tx4509 tx10432 NSChangeSpellingtab A message in this protocol (b changeSpelling:b0 ) is sent down the responder chain when the user presses the Correct button.
fs16 
fs28 fi-3655 fi-3655 NSIgnoreMisspelledWords tab When the object being checked responds to this protocol, the spell server keeps a list of words that are acceptable in the document and enables the Ignore button in the Spelling panel.
fs16 
fs28 fi-3655 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 The application may choose to split a document'27s text into segments and check them separately. This will be necessary when the text has segments in different languages. Spell checking is invoked for one language at a time, so a document that contains portions in three languages will require at least three checks.
fs16 
fs28 pard s15 li477 fi0 ri1007 ql f0 b fs24 fs4 
fs24 Dictionaries and Word Lists
pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs28 fs16 
fs28 The process of checking spelling makes use of three references:
fs16 
fs28 pard s3 li1231 fi-376 ri1007 ql tx1231 tx2872 tx3250 'b7tab A dictionary registered with the system'27s spell-checking service. When the Spelling panel first appears, by default it shows the dictionary for the user'27s preferred language. The user may select a different dictionary from the list in the Spelling panel.
fs16 
fs28 'b7tab The user'27s fs28 'aafs28 learnfs28 'bafs28  list of correctly-spelled words in the current language. The NSSpellChecker updates the list when the user presses the Learn or Forget buttons in the Spelling panel.
fs16 
fs28 'b7tab The document'27s list of words to be ignored while checking it (if the first responder conforms to the NSIgnoreMisspelledWords protocol). The NSSpellChecker updates its copy of this list when the user presses the Ignore button in the Spelling panel.
fs16 
fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 A word is considered to be misspelled if none of these three accepts it. 
fs16 
fs28 pard s15 li477 fi0 ri1007 ql f0 b fs24 fs4 
fs24 Matching a List of Ignored Words with the Document It Belongs To
pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs28 fs16 
fs28 Tfs28 he NSString being checkedfs28  isn'27t the same as fs28 the fs28 document. In the course of processing a document, an application might run several checks based on different parts or different versions of the text. But they'27d all belong to the same document. The NSSpellChecker keeps a separate fs28 'aafs28 ignored wordsfs28 'bafs28  list for each document that it checks. To help match fs28 'aafs28 ignored wordsfs28 'bafs28  lists to documents, you should call b uniqueSpellDocumentTagb0  once for each document. This method returns a unique arbitrary integer that will serve to distinguish one document from the others being checked and to match each fs28 'aafs28 ignored wordsfs28 'bafs28  list to a document. When searching for misspelled words, pass the tag as the fourth argument of b checkSpellingOfString:startingAt:language:wrap:inSpellDocumentWithTag:wordCount:b0 . (The convenience method b checkSpellingOfString:startingAt:b0  takes no tag. This method is suitable when the first responder does not conform to the NSIgnoreMisspelledWords protocol.) 
fs16 
fs28 When the application saves a document, it may choose to retrieve the fs28 'aafs28 ignored wordsfs28 'bafs28  list and save it along with the document. To get back the right list, it must send the NSSpellChecker an b ignoredWordsInSpellDocumentWithTag:b0  message. When the application has closed a document, it should notify the NSSpellChecker that the document'27s fs28 'aafs28 ignored wordsfs28 'bafs28  list can now be discarded, by sending it a b closeSpellDocumentWithTag:b0  message. When the application reopens the document, it should restore the 'aaignored words'ba list with the message b setIgnoredWords:inSpellDocumentWithTag:b0 . 
fs16 
fs28 pard s16 li100 fi0 ri1007 ql f0 b fs24 
fs28 Making a Checker available 
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 + (NSSpellChecker *)b sharedSpellCheckerb0 tab Returns the NSSpellChecker (one per application). 
fi-6552 fs16 
fs28 fi-6552 + (BOOL)b sharedSpellCheckerExistsb0 tab Returns whether the application'27s NSSpellChecker has already been created. 
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Managing the Spelling Panel 
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (NSView *)b accessoryViewb0 tab Returns the Spelling panel'27s accessory NSView object. 
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b setAccessoryView:b0 (NSView *)i aViewi0 tab Makes an NSView object an accessory of the Spelling panel by making it a subview of the panel'27s content view. This method posts the notification NSWindowDidResizeNotification with the Spelling panel object to the default notification center.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (NSPanel *)b spellingPanelb0 tab Returns the NSSpellChecker'27s panel. 
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Checking Spelling 
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (int)b countWordsInString:b0 (NSString *)i aStringi0 tab Returns the number of words in i stringi0 . The i languagei0  
s9 li7030 fi-6553 fi-5796 b language:b0 (NSString *)i languagei0 tab tab argument specifies the language used in the string. If i languagei0  is the empty string, the current selection in the Spelling panel'27s pop-up menu is used.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (NSRange)b checkSpellingOfString:b0 (NSString *)i stringToCheck
s9 li7030 fi-6553 fi-5796 i0 b startingAt:b0 (int)i startingOffseti0 tab Starts the search for a misspelled word in i stringToChecki0  starting at i startingOffseti0  within the string object. Returns the range of the first misspelled word. Wrapping occurs but no ignored-words dictionary is used.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (NSRange)b checkSpellingOfString:b0 (NSString *)i stringToCheck
s9 li7030 fi-6553 fi-5796 i0 b startingAt:b0 (int)i startingOffsettab i0 Starts the search for a misspelled word in i stringToCheck
i0 b language:b0 (NSString *)i languagei0 tab tab starting at i startingOffseti0  within the string object.
b wrap:b0 (BOOL)i wrapFlagi0 tab tab Returns the range of the first misspelled word and
b inSpellDocumentWithTag:b0 (int)i tagi0 tab tab optionally the word count by reference. i tagi0  is an
b wordCount:b0 (int *)i wordCounti0 tab tab identifier unique within the application used to inform the spell check which document (actually, a dictionary) of ignored words to use. i wrapFlagi0  determines whether spell checking continues at the beginning of the string when the end is reached. i languagei0  is the language used in the string. If i languagei0  is the empty string, the current selection in the Spelling panel'27s pop-up menu is used.
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Setting the Language 
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (NSString *)b languageb0 tab Returns the current language used in spell-checking.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (BOOL)b setLanguage:b0 (NSString *)i aLanguagei0 tab Sets the language to use in spell-checking to i aLanguagei0 . Returns whether the Language pop-up list in the Spelling panel lists i aLanguagei0 .
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Managing the Spelling Process 
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 + (int)b uniqueSpellDocumentTagtab b0 Returns a guaranteed unique tag to use as the spell-document tag for a document. Use this method to generate tags to avoid collisions with other objects that can be spell-checked.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b closeSpellDocumentWithTag:b0 (int)i tagi0 tab Notifies the NSSpellChecker that the user has finished with the ignored-word document identified by i tagi0 , causing it to throw that dictionary away. 
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b ignoreWord:b0 (NSString *)i wordToIgnoretab i0 Instructs the NSSpellChecker to ignore all future 
s9 li7030 fi-6553 fi-5796 b inSpellDocumentWithTag:b0 (int)i tagtab tab i0 occurrences of i wordToIgnorei0  in the document identified by i tagi0 . You should call this method from within your implementation of the NSIgnoreMisspelledWords protocol'27s b ignoreSpelling:b0 .
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (NSArray *)b ignoredWordsInSpellDocumentWithTag:b0 (int)i tag
s9 li7030 fi-6553 fi-5796 i0 tab Returns the array of ignored words for a document identified by i tagi0 . Invoke this before b closeSpellDocument:b0  if you want to store the ignored words.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b setIgnoredWords:b0 (NSArray *)i someWordstab i0 Initializes the ignored-words document (i.e., dictionary 
s9 li7030 fi-6553 fi-5796 b inSpellDocumentWithTag:b0 (int)i tagi0 tab  tab identified by i tagi0  with i someWordsi0 , an array of wordsi  i0 to ignore.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b setWordFieldStringValueb0 :(NSString *)i aString
s9 li7030 fi-6553 fi-5796 i0 tab Sets the string that appears in the misspelled word field, using the string object i aStringi0 .
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b updateSpellingPanelWithMisspelledWord:b0 (NSString *)i word
s9 li7030 fi-6553 fi-5796 i0 tab Causes NSSpellChecker to update the Spelling panel'27s misspelled-word field to reflect i wordi0 . You are responsible for highlighting i wordi0  in the document and for extracting it from the document using the range returned by the b checkSpelling:...b0  methods. Pass the empty string as i wordi0  to have the system beep, indicating no misspelled words were found.

}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.