문제

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.

도움이 되었습니까?

해결책

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

[self.displayTimerTotalTime fire];

다른 팁

You could always call the selector yourself:

[self timerFiredTotalTime:self.displayTimerTotalTime];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top