let toBeString = textView.text
let lang = textView.textInputMode?.primaryLanguage
if lang == "zh-Hans" {
let selectedRange = textView.markedTextRange
if selectedRange == nil && (toBeString?.characters.count)! > 50{
let index = toBeString?.index((toBeString?.startIndex)!, offsetBy: 50)
textView.text = toBeString?.substring(to:index!)
}
}else if (toBeString?.characters.count)! > 50 {
let index = toBeString?.index((toBeString?.startIndex)!, offsetBy: 50)
textView.text = toBeString?.substring(to:index!)
} |