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");
}
//Here i used UITextChecker Function ,even for the wrong word, the above function shows correct word statement eg: wrong word like abcd, bcde, cdef, CAPs, kindly help me what is the reason behind this. Is there any other option to solve this?
Thanks in advance
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;
}