Use this class method to schedule a timer.
+(NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)repeats
Options
seconds
The number of seconds between timer shooting. If seconds are less than or equal to 0.0, this method selects a non-negative value of 0.1 milliseconds instead.
target
The object to send the message specified by aSelector when the timer fires. The target is saved by the timer and freed when the timer is invalid.
aSelector
The message sent to the target when the timer fires. The selector must have the following signature:
- (void) timerFireMethod: (NSTimer *) theTimer
The timer passes itself as an argument to this method.
USERINFO
User information for the timer. The specified object is saved by the timer and released when the timer is invalid. This parameter may be zero.
repeats
If YES, the timer will redirect itself until it is canceled. If NO, the timer will be invalid after it occurs.
Example
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(targetMethod:) userInfo:[self userInfo] repeats:NO];
The timer starts automatically after 2 seconds. Timer Programming Topics
Parag bafna
source share