I'd like to write a code that says the number increases with time.
As shown in the code below, we can increase the number every second, but
You cannot increase a decimal number, such as every 0.25 seconds.
I tried various methods, but it didn't work well, so I got stuck.
iflet=self.startTime{
let time —Double=NSDate.timeIntervalSinceReferenceDate()-t+self.elappedTime
letsec: Int=Int(time)
let msec: Int=Int(time-Double(sec))*100.0)
self.timerLabel.text=NSString(format: "%02d:%02d:%02d:%02d", sec/60, sec%60, msec) as String
self.resultLabel.text=NSString(format: "%01d", sec*4) as String
}
of the above code
self.resultLabel.text=NSString(format: "%01d", sec*4)asString
The part is the label that increases the number.
Currently, the number increases by 4 in 1 second, but
I would like to set this to increase the number by 1 in 0.25 seconds.
If you do not have enough information, I will add it, so please let me know.
Thank you for your cooperation.
ios swift xcode iphone
letsec: Int=Int(time)
has reduced the granularity of the data, so even if you multiply it by four times, it will only increase by four per second.
iflet=self.startTime{
let time —Double=NSDate.timeIntervalSinceReferenceDate()-t+self.elappedTime
letsec: Int=Int(time)
letsec4: Int=Int(time*4)
let msec: Int=Int(time-Double(sec))*100.0)
self.timerLabel.text=NSString(format: "%02d:%02d:%02d:%02d", sec/60, sec%60, msec) as String
self.resultLabel.text=NSString(format: "%01d", sec4) as String
}
I think it would be good to say that
© 2024 OneMinuteCode. All rights reserved.