1

I have very simple "if" statement which is part of a stopwatch, it works when the increment 1 but not 0.1! My timer has a timeInterval of 0.1 I tried to simulate this issue in a different test project which has 2 label fields and Runs button no timer involved, only works while you incrementing by pressing the button, unfortunately, I have the same result. Can you please tell me why this happening? Thanks,

func updateTimer() {

    counter += 0.1

    if counter == 1 {
        oF = oF + 1 // only works if counter +=1

        overFlow.text = String ( oF)
    } else {
        timeLabel.text = String(format: "%.1f", counter)


    }
Farisk
  • 83
  • 7

0 Answers0