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

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -