如果没有找到更正,UITextChecker‘rangeOfMisspelledWordInString:range:startingAt:wrap:language:将返回零。然而,我想知道是否有一种方法可以判断是否发现没有更正,因为A已经是正确的,或者B。对于当前的单词,什么都不存在。
这就是我现在拥有的:
if (!arrayOfPossibleCorrections || !arrayOfPossibleCorrections.count) {
//If nothing found bc it's already correct leave it alone
//Else dosomething
} else {
//Replace currentWord with correctWord
}发布于 2014-11-19 03:51:10
从苹果开发者库,rangeOfMisspelledWordInString返回{NSNotFound, 0},如果没有发现拼写错误的单词,这正是您想要的。
如果没有找到更正,则返回空数组的是guessesForWordRange。
简而言之,只有当guessesForWordRange返回拼写错误的单词范围时,才应该调用rangeOfMisspelledWordInString。
https://stackoverflow.com/questions/26984982
复制相似问题