0
votes

I am creating an application in that I need to use about 20 different Timers.

But all the timers are going to be created at run time, by calling some function.

All the timers might having different timer interval and all timer do have different counters that will be reduced by one with passing of 1 minute.

Now when the counter will become 0 the timer will be stopped. But in my application all timers have different counter values and I want to stop different timers at it's time interval using a single function.

I know that we can create different timers and by providing the selector values to their respective timer functions , we can stop the timer by I don't have idea that how many timers are running at a time , and if I do stop a single timer at a time then it will lead to stop all the timers and the functionality is not showing properly.

Please help me by providing any logic or samples How to stop multiple timers using single function at different time interval.

thanks in advance

1

1 Answers

0
votes

I think you may want to reconsider your software design. You can call your method as normal:

[self method];

And then at the end of each method, do the following:

[self performSelector:@selector(method) withObject:nil afterDelay:(1000)];

This will create a loop. You can then increment an integer and do something else when that counter reaches 0. You'll be able to manage your code much more effectively. You may still need timers for some situations, but this will definitely be more efficient than the 20 timers you were planning on using.