-2

So imagine I want my code to count in 0.25, and I want it to be like: 0.00, 0.25, 0.50... but it's currently like: 0, 0.25, 0.5... That part of my code like this:

if (Score >= 0 && Score < 10.00){
    Score += 0.25
    HighScoreLabel.text = "The Score is \(Score)"
}
Juan Catalan
  • 2,299
  • 1
  • 17
  • 23
Gabe12
  • 607
  • 1
  • 7
  • 25

1 Answers1

4
let score = 0.5
let stringDisplay = String(format: "%.02f", score)
println("The Score is \(stringDisplay)")   // "The Score is 0.50"

String Format Specifiers

Leo Dabus
  • 229,809
  • 59
  • 489
  • 571