开发者

I need to create a timer that has hour, mins, and seconds

开发者 https://www.devze.com 2023-04-09 17:55 出处:网络
I currently have code that can display mins and seconds. But the problem I\'m facing is that when the mins gets to 60, it cou开发者_JAVA百科nts up to 61 and beyond.

I currently have code that can display mins and seconds. But the problem I'm facing is that when the mins gets to 60, it cou开发者_JAVA百科nts up to 61 and beyond.

How can I add the hours?

-(void)update:(ccTime)dt{

        totalTime += dt;
        currentTime = (int)totalTime;
    if (myTime < currentTime)
{
    myTime = currentTime;
    [countUpTimer setString:[NSString stringWithFormat:@"%02d:%02d", myTime/60, myTime%60]];
}
}


[countUpTimer setString:[NSString stringWithFormat:@"%02d:%02d:%02d", myTime/3600, (myTime/60)%60, myTime%60]];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号