Nstimer not invalidating ways of dating

Rated 4.34/5 based on 754 customer reviews

If you send this message from another thread, the input source associated with the timer may not be removed from its run loop, which could prevent the thread from exiting properly.

I have 4 NSTimers in my app , that make requests to a rest url every few seconds.

NOTE: All timers are in different class and I'm trying to invalidate the timers in another class Any help will be appreciated , thank you.

Run loops maintain strong references to their timers, so you don’t have to maintain your own strong reference to a timer after you have added it to a run loop.

To use a timer effectively, you should be aware of how run loops operate.

nstimer not invalidating-42

It seems like the invalidation in the "encounter error" method didnt work. The timer invalidation should happen on the thread where it is scheduled, in above case it is called on another thread (call backs).For example, if a timer is scheduled to fire at a particular time and every 5 seconds after that, the scheduled firing time will always fall on the original 5-second time intervals, even if the actual firing time gets delayed.If the firing time is delayed so far that it passes one or more of the scheduled firing times, the timer is fired only once for that time period; the timer is then rescheduled, after firing, for the next scheduled firing time in the future.).Basically any time your view actually reappears on screen, not just the first time.So in this case the timer gets restarted, even though is was invalidated before.

Leave a Reply