Re: NSSpellChecker Count Words
Re: NSSpellChecker Count Words
- Subject: Re: NSSpellChecker Count Words
- From: Timothy Ritchey <email@hidden>
- Date: Tue, 4 Feb 2003 14:54:21 -0500
Okay, just for the record in case someone runs across this in the
future, this works:
- (IBAction)wordCount:(id)sender
{
// count the words, and log to the command line
int wordCount = 0, count = 0;
NSRange range;
while(range.location != NSNotFound) {
range = [[NSSpellChecker sharedSpellChecker]
checkSpellingOfString:
[[textViewController xmlTextStorage] string]
startingAt:NSMaxRange(range)
language:@""
wrap:NO
inSpellDocumentWithTag:0
wordCount:&count];
wordCount += count;
}
// ...
}
On Tuesday, February 4, 2003, at 02:37 PM, Douglas Davidson wrote:
On Monday, February 3, 2003, at 07:19 AM, Timothy Ritchey wrote:
I was wondering if anyone had any insights into using NSSpellChecker
to count the number of words in a string. I am using it like:
int count = [[NSSpellChecker sharedSpellChecker]
countWordsInString:aString language:@""];
No matter what I seem to do, I always get zero.
This is due to a bug in our spellcheckers. They currently don't count
words unless they're checking spelling at the same time.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.