Add a timer in an iPhone application

Here is the code to add a timer object to an iPhone application

NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(startTimer) userInfo:NULL repeats:YES];   

scheduledTimerWithTimeInterval – This is the time interval for timer to call a method

selector – This is the method which runs after the interval

repeats – If the user wants continuously run the particular method after the interval, this must be assigned as YES. Otherwise this will be NO.

No comments: