In this question (iPhone objective-c: detecting a 'real' word) the function returns the following line as true if the word is a 'real word'

return misspelledRange.location == NSNotFound;

I'm confused as to why this is "==" and not "!=". Wouldn't it make sense that "not equal to NSNotFound" would mean that the word was found -- as seems to be the case in this answer Can NSRange determine if a snippet of text exists in a larger string? ?

有帮助吗?

解决方案

If I understand it correctly, that function returns true if the given word does not contain a misspelled word, so

return misspelledRange.location == NSNotFound;

makes sense.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top