I get an error while using UITextChecker in Swift 4. The following code most likely works for Swift 3, I'm just not sure what's the problem in Swift 4? Here is my code:
import UIKit
var correctStr : String = String()
let str = "Helo"
let textChecker = UITextChecker()
let misspelledRange = textChecker.rangeOfMisspelledWordInString(
str, range: NSRange(0..<str.utf16.count),
startingAt: 0, wrap: false, language: "en_US")
if misspelledRange.location != NSNotFound,
let guesses = textChecker.guessesForWordRange(
misspelledRange, inString: str, language: "en_US") as? [String]
{
correctStr = guesses.first
}
and I receive this error: "use of unresolved identifier 'UITextChecker'.
Your help would be greatly appreciated.
The APIs
rangeOfMisspelledWordInString
andguessesForWordRange
have been renamed, your code should read: