Класс UITextChecker может быть тем, что вы ищете на iOS
https://developer.apple.com/documentation/uikit/uitextchecker
Пример реализации:
func isActualWord(wordToCheck: String) -> Bool {
let textChecker = UITextChecker()
let language = "en"
let range = NSRange(location: 0, length: wordToCheck.utf16.count)
let query = textChecker.rangeOfMisspelledWord(in: wordToCheck, range: range, startingAt: 0, wrap: false, language: language)
return query.location == NSNotFound
}
isActualWord(wordToCheck: "Swift") //true
isActualWord(wordToCheck: "Swifty") //false
func suggestedWords(wordToCheck: String) -> [String]? {
let textChecker = UITextChecker()
let language = "en"
let range = NSRange(location: 0, length: wordToCheck.utf16.count)
let suggestedWords = textChecker.guesses(forWordRange: range, in: wordToCheck, language: language)
return suggestedWords
}
suggestedWords(wordToCheck: "Swifty") // ["Swiftly", "Swifts", "Shifty", "Swift"]