Re: Word Count Problem
Re: Word Count Problem
- Subject: Re: Word Count Problem
- From: cricket <email@hidden>
- Date: Mon, 3 May 2004 16:16:25 -0700
Minor correction to earlier post:
On May 3, 2004, at 3:55 PM, Matt Ball wrote:
while(range.location != NSNotFound)
{
range = [[NSSpellChecker sharedSpellChecker]
checkSpellingOfString:textDocument startingAt:0 language:@"" wrap:YES
inSpellDocumentWithTag:0 wordCount:&count];
wordCount += count;
}
This block here will end up in an infinite loop if the document
contains misspelled words -- range.location will end up being something
other than NSNotFound, then the loop will repeat, starting at the
beginning of the string again.
If you have an application hanging, Sampler is a good tool to use to
troubleshoot it. Also, stepping through your block of code in XCode or
gdb would quickly reveal that you're stuck in the while loop forever.
- cricket
It works fine for documents that have not set off a red flag in the
spellchecker. As soon as the document contains a word that the
spellchecker doesn't know, the word count stops working. The app
freezes when I try to do a word count. Can anyone offer any insights as
to why this is happening?
_______________________________________________
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.