Below is test code I wrote in a Swift Playground. It shows UITextChecker is not working reliably.

   import UIKit

func validWord(word: String) -> Bool {
    let checker = UITextChecker()
    let range = NSRange(location: 0, length: word.utf16.count)
    let misspelledRange = checker.rangeOfMisspelledWord(in: word, range: range, startingAt: 0, wrap: false, language: "en")
    
    return misspelledRange.location == NSNotFound
}

for char in "abcdefghijklmnopqrstuvwxyz" {
    let word = String(repeating: char, count: 5)
    print("\(word): \(validWord(word: word) ? "Valid" : "Misspelled")")
    print("\(word.uppercased()): \(validWord(word: word.uppercased()) ? "Valid" : "Misspelled")")
}

Here are the results: aaaaa: Misspelled AAAAA: Valid bbbbb: Misspelled BBBBB: Valid ccccc: Valid CCCCC: Valid ddddd: Valid DDDDD: Valid eeeee: Misspelled EEEEE: Valid fffff: Misspelled FFFFF: Valid ggggg: Misspelled GGGGG: Valid hhhhh: Misspelled HHHHH: Valid iiiii: Valid IIIII: Valid jjjjj: Misspelled JJJJJ: Valid kkkkk: Misspelled KKKKK: Valid lllll: Valid LLLLL: Valid mmmmm: Valid MMMMM: Valid nnnnn: Misspelled NNNNN: Valid ooooo: Misspelled OOOOO: Valid ppppp: Misspelled PPPPP: Valid qqqqq: Misspelled QQQQQ: Valid rrrrr: Misspelled RRRRR: Valid sssss: Misspelled SSSSS: Valid ttttt: Misspelled TTTTT: Valid uuuuu: Misspelled UUUUU: Valid vvvvv: Valid VVVVV: Valid wwwww: Valid WWWWW: Valid xxxxx: Valid XXXXX: Valid yyyyy: Misspelled YYYYY: Valid zzzzz: Misspelled ZZZZZ: Valid

I would expect consistent results over the entire alphabet.

0

There are 0 answers