NSTimer with multiple time intervals in a sequence
intervals, ios, nstimer, objective-c
Solution
I'm not sure what your final goal is with this but after reading your question I would recommend to try the following way, maybe this is what you'd look for.
you should put this code where you normally wanted to start the same `NSTimer` class with different intervals (what is not possible, unfortunately).
{
// ...
[self performSelector:@selector(method1) withObject:nil afterDelay:0.3f];
[self performSelector:@selector(method2) withObject:nil afterDelay:0.5f];
[self performSelector:@selector(method3) withObject:nil afterDelay:0.7f];
// ...
}
and when need to unschedule all those selectors queued, use this code.
[NSObject cancelPreviousPerformRequestsWithTarget:self];
Problem
Without creating multiple `NSTimer` instances, how would one achieve an `NSTimer` to fire a specific or multiple method with different intervals in a sequence. For example method1 (0.3 sec), method2 (0.5), method3 (0.7) and so on. I would appreciate if someone could please share any example code.