Question

Is it possible to make a NStimer that fires first when it is initialized and then afterwards on a 0.01 seconds schedule? I have this code..

 self.displayTimerTotalTime = [NSTimer timerWithTimeInterval:0.01
 target:self
 selector:@selector(timerFiredTotalTime:)
 userInfo:nil repeats:YES];
 [[NSRunLoop mainRunLoop] addTimer:self.displayTimerTotalTime forMode:NSRunLoopCommonModes];

Problem is that the user can stop the timer multiple times and run it again, but this creates a 0.01 delay every time that can cause problems for the user experience. It is not good enough to check for the delay later and remove it.

Était-ce utile?

La solution

You can call the -fire method to fire the timer at any time. Just add this after the above code:

[self.displayTimerTotalTime fire];

Autres conseils

You could always call the selector yourself:

[self timerFiredTotalTime:self.displayTimerTotalTime];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top