Xcode 8에서 Apple의 UITextChecker를 사용하여 단어의 철자 오류를 자동으로 검색하고 대체 단어를 제안하려고합니다. 필자는 Apple API를 참조하는 것이 상대적으로 처음이므로 어떤 도움을 주시면 감사하겠습니다.스위프트가있는 UITextChecker
감사합니다. 언어 매개 변수는 선택 사항입니다
func correctWord(word: String, language: String = "en") -> 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: language)
return misspelledRange.location == NSNotFound
}
참고,하지만 당신은 "en"
에서 언어를 변경하려는 경우 당신이 그것을 전달할 수 : 여기
그래서 당신은 무엇을 시도? 귀하의 질문은 매우 광범위하며 특정 문제가 아닙니다. 아니면 우리가 당신을 위해 그것을 쓰길 기대합니까? [묻는 방법] (http://stackoverflow.com/help/how-to-ask) – AgataB