Re: Word Count Problem
Re: Word Count Problem
- Subject: Re: Word Count Problem
- From: Matt Ball <email@hidden>
- Date: Mon, 3 May 2004 21:36:18 -0400
That makes sense. Any idea how to fix it? Or even another method to do
a word count? Thanks
-- Matt Ball
On May 3, 2004, at 7:16 PM, cricket wrote:
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.
_______________________________________________
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.