scheduledTimerWithTimeInterval :invocation:repeats:
Creates and returns a new
NSTimer
object and schedules it on the current run loop in the default mode.
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds invocation:(NSInvocation*)invocation repeats:(BOOL)repeats
Parameters
- seconds
- The number of seconds between firings of the timer. If seconds is less than or equal to
0.0
, this method chooses the nonnegative value of 0.1 milliseconds instead. - invocation
- The invocation to use when the timer fires. The timer instructs the invocation object to retain its arguments.[NSTimer scheduledTimerWithTimeInterval]
- repeats
- If
YES
, the timer will repeatedly reschedule itself until invalidated. IfNO
, the timer will be invalidated after it fires.
Return Value of [NSTimer scheduledTimerWithTimeInterval]
A new
NSTimer
object, configured according to the specified parameters.Discussion
After seconds seconds have elapsed, the timer fires, invoking invocation.
Example of [NSTimer scheduledTimerWithTimeInterval]
- (void) viewDidLoad {
NSInvocation *updateDisplayInvocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector: @selector (myMethod)]];
[updateDisplayInvocation setSelector: @selector (myMethod)];
[updateDisplayInvocation setTarget: self];
NSTimer *audioDisplayUpdateTimer;
audioDisplayUpdateTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 invocation:updateDisplayInvocation repeats:YES];
[super viewDidLoad];
}
- (void) myMethod {
NSLog(@"Method execution");
}