ios - How to display hh:mm:ss in NSTimer? -


hello i'm trying make simple countdown app.

however countdown in seconds , not in minutes , hours. how make such?

create timer:

timer = [nstimer scheduledtimerwithtimeinterval: 1.0 target:self selector:@selector(countdown) userinfo:nil repeats: yes]; 

countdown method:

-(void) countdown {     int hours, minutes, seconds;      secondsleft--;     hours = secondsleft / 3600;     minutes = (secondsleft % 3600) / 60;     seconds = (secondsleft %3600) % 60;     label.text = [nsstring stringwithformat:@"%02d:%02d:%02d", hours, minutes, seconds]; } 

reference : https://developer.apple.com/library/ios/documentation/cocoa/conceptual/timers/articles/usingtimers.html


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -