Ordinary timer implementation

Source: Internet
Author: User

Timer code: _hour,_minute initial value is 0;

Calculation time

-(void) time

{

Execute @selector after 60 seconds: method

_timer = [nstimer scheduledtimerwithtimeinterval:60.0f target: Self Selector:@selector(updatetimer:) userInfo:nil repeats:YES];

< Span class= "S6" > < Span class= "S3" >//is displayed when the minute is 0: time 0:0

_iwifiview. Onlinetime. Text = [nsstring stringwithformat:@ "%d time%d ", _hour, _ Minute];

}

-(void) Updatetimer: (nstimer *) sender{

Output test

NSLog(@ " time %d %d ", _hour, _minute );

When 1 hours are reached, change the display time of the hour and let the minutes start again from zero

if (_minute = = ) {

_hour++;

_minute = 0;

}else{

_minute++;

}

Time is a label, and it is displayed with a label

_time. Text = [nsstring stringwithformat:@ "%d time%d ", _hour , _minute];

}

Ordinary timer implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.