I go back to some cool code to tidy it up, and I see that I keep NSTimers being returned from scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:and keeping them in the field, and then freeing and nullifying the field when it starts. In some cases, I use a timer to send him an invalid message later, but in many cases not.
In later code, I usually just schedule a timer and forget about it. I understand that the constructor method is auto-implemented, and the timer is stored in the startup loop while it is active, so I do not see any problems with this.
So, just to finish my understanding - is there any other reason I should hold on to my timers, or what am I doing now on the accepted idiom?
This is all in the context of iPhone code, but I don’t think it is an iPhone.
source
share