Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is there timer in ios

Tags:

iphone

ipad

I want to create a timer for example to count 2 sec and after each second an nslog type for example 1 sec passed

any suggestion to do that

like image 472
AMH Avatar asked May 05 '11 13:05

AMH


3 Answers

yes there is NSTimer, use it as -

[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector() userInfo:nil repeats:NO];
like image 171
saadnib Avatar answered Oct 02 '22 12:10

saadnib


What you're after is NSTimer.

Which, I can't not point out, even a cursory search of the framework docs would have turned up. Laziness IS one of the three Virtues of the Programmer, but c'mon.

like image 42
Dan Ray Avatar answered Oct 02 '22 11:10

Dan Ray


You can call your NSTimer like this

[NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(changeValue) userInfo:nil repeats:YES];

changeValue function can be like

-(void)changeValue{
    NSLog("calling function after every two seconds");
}
like image 28
Inam Abbas Avatar answered Oct 02 '22 12:10

Inam Abbas