I'm trying to update a UILabel with the amount of time left on an audio track in minutes and seconds. I'm getting an Invalid operand to binary % error . Here's the code:
 - (void)updateTimeLeft
{
        NSTimeInterval timeLeft = self.player.duration - self.player.currentTime;
        int min = timeLeft / 60;
        int sec = timeLeft % 60;
        self.timeDisplay.text = [NSString stringWithFormat:@"%d : %d", min,sec];
}
I changed the code to the following:
int sec = lroundf(timeLeft) % 60;
The error goes away, but I suspect that there's a problem here because the timer counts down correctly from 5:00 to 4:10, 开发者_如何学运维but then displays 4:9 instead of 4:09
thanks for the help
Alterations below,
self.timeDisplay.text = [NSString stringWithFormat:@"%02d:%02d", min,sec];
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论