Ios 下面的UITextChecker函数工作不正常

Ios 下面的UITextChecker函数工作不正常,ios,ipad,ios5,ios4,Ios,Ipad,Ios5,Ios4,//这里我使用了UITextChecker函数,即使对于错误的单词,上面的函数也会显示正确的单词语句 像abcd这样的错误单词, bcde, cdef, CAPs,请帮帮我这背后的原因是什么。有没有其他解决办法 提前感谢NSNotFound意味着你要的东西都找不到了=是相等运算符。当范围时,您的代码将打印“Word found”。位置等于NSNotFound 我想你应该给[[UITextChecker availableLanguages]objectAtIndex:0]来获取英语。你能试试da

//这里我使用了UITextChecker函数,即使对于错误的单词,上面的函数也会显示正确的单词语句 像abcd这样的错误单词, bcde, cdef, CAPs,请帮帮我这背后的原因是什么。有没有其他解决办法


提前感谢

NSNotFound意味着你要的东西都找不到了<代码>=是相等运算符。当
范围时,您的代码将打印“Word found”。位置
等于
NSNotFound

我想你应该给
[[UITextChecker availableLanguages]objectAtIndex:0]
来获取英语。你能试试dat吗?我把对象索引改为0,它不能正常工作
NSString * currentWord;
        currentWord = Text.text;
        UITextChecker* checker = [[UITextChecker alloc] init];
        NSString* preferredLanguage = [[UITextChecker availableLanguages] objectAtIndex:0];
        NSRange range;
 range = [checker rangeOfMisspelledWordInString:currentWord
                                                 range:NSMakeRange(0, [currentWord length])
                                            startingAt:0
                                                  wrap:NO
                                              language:preferredLanguage];
        if (range.location == NSNotFound)
        {
            NSLog(@"Word found");
        }
        else
        {
            NSLog(@"Word not found");
        }
NSNotFound
    UITextChecker *Checker = [[UITextChecker alloc] init];

    NSRange range = NSMakeRange(0, inputWord.length);


    NSRange misspelledRange = [Checker rangeOfMisspelledWordInString:[Sentence lowercaseString] range:range startingAt:0 wrap:NO language:@"en_IN"];

    bool isValidWord = misspelledRange.location == NSNotFound;

    //NSLog(@"----%i", misspelledRange.location);
    if (isValidWord)
    {
        isValidWord = [self checkIfWordExistsInSuggestedSpellings:Sentence];
        NSLog(@"++++%d", isValidWord);

    }

    return isValidWord;

}
else
{
     NSLog(@"Invalid word");
    return false;

}