I want to display variables 10 in order up to 1, 2, 3 ...

@AppStorage("exhaleTimer_Value") var exhaleTimerValue = 10

I want to display this variable 10 in order up to 1, 2, 3 ...

How can I do this? please answer.

Answered by Claude31 in 687434022

I want to display this variable 10 in order up to 1, 2, 3 ...

Could you clarify what you want ?

Do you mean displaying numbers up to 10, with a 1 s interval for instance ?

If so you can simply use timer:

     @IBOutlet weak var progressLabel: UILabel!   

     var count = 0
     @objc func fire() {
          count += 1
          progressLabel.text = " \(count)"
          if count >= 10 { timer.invalidate()}
     }

// In the func where you trigger the count up

timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(fire), userInfo: nil, repeats: true)
Accepted Answer

I want to display this variable 10 in order up to 1, 2, 3 ...

Could you clarify what you want ?

Do you mean displaying numbers up to 10, with a 1 s interval for instance ?

If so you can simply use timer:

     @IBOutlet weak var progressLabel: UILabel!   

     var count = 0
     @objc func fire() {
          count += 1
          progressLabel.text = " \(count)"
          if count >= 10 { timer.invalidate()}
     }

// In the func where you trigger the count up

timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(fire), userInfo: nil, repeats: true)
I want to display variables 10 in order up to 1, 2, 3 ...
 
 
Q