jeudi 26 mars 2015

Trim end off of string in swift, getting error

Am making a calculator app in swift, once my answer is obtained I want to display it in a UILabel. Only problem is I want to limit said answer to 8 characters. Here is my code:



let answerString = "\(answer)"
println(answer)
calculatorDisplay.text = answerString.substringToIndex(advance(answerString.startIndex, 8))


This does not return any compiler errors but at runtime I get:



fatal error: can not increment endIndex


Any and all help would be greatly appreciated.


Aucun commentaire:

Enregistrer un commentaire