SlopTonio SlopTonio - 1 month ago 6
iOS Question

Cannot invoke substringToIndex with an arguement list type int

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

Answer

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))