You can use this extension:
Swift 2.3
extension String { func substringToIndex(index: Int) -> String { if (index < 0 || index > self.characters.count) { print("index \(index) out of bounds") return "" } return self.substringToIndex(self.startIndex.advancedBy(index)) } }
Swift 3
extension String { func substring(to index: Int) -> String { if (index < 0 || index > self.characters.count) { print("index \(index) out of bounds") return "" } return self.substring(to: self.characters.index(self.startIndex, offsetBy: index)) } }
And use:
textView.text = textView.text.substringToIndex(textView.text.characters.count - 1)
source share