Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot invoke substringToIndex with an arguement list type int

Tags:

ios

swift

I'm trying to get this line to work:

textView.text = textView.text.substringToIndex(count(textView.text.utf16) - 1)

error: Cannot invoke substringToIndex with an arguement list type int

like image 863
SlopTonio Avatar asked Mar 15 '23 06:03

SlopTonio


1 Answers

substringToIndex takes a String.Index which is different from an Int. If you want to take the whole string minus the last character, you could do

textView.text = textView.text.substringToIndex(advance(textView.text.endIndex, -1))
like image 138
David Skrundz Avatar answered May 07 '23 05:05

David Skrundz