I want to use UITextChecker to find the wrong word. Unfortunately, my code does not work as I expected. Can anyone correct my mistake, please? Here is my code. https://i.stack.imgur.com/4Ib8e.png
Thanks for helping me.
I want to use UITextChecker to find the wrong word. Unfortunately, my code does not work as I expected. Can anyone correct my mistake, please? Here is my code. https://i.stack.imgur.com/4Ib8e.png
Thanks for helping me.
your code working properly
func isCorrect(word:String)->Bool{
let checker = UITextChecker()
let range = NSRange(location: 0, length: word.utf16.count)
let mispelledRange = checker.rangeOfMisspelledWord(in: word, range: range, startingAt: 0, wrap: false, language: "en")
return mispelledRange.location == NSNotFound
}
print(isCorrect(word: "apple"))
print(isCorrect(word: "ppale"))
Here you can find the example for
UITextChecker
Consider the example below: