tags:

views:

346

answers:

1

hai i want to know the difference between invalidate and release of timer.... what is the best way to deallocate it?

+4  A: 

The two methods do different things. If you own a timer (you retained it, or alloced it, or copied it) then you should release it. If you scheduled it on a run loop, then you must invalidate it for the run loop to release it. If you did both things, then you must release and invalidate the timer (however usually having the run loop owning the timer is sufficient).

Graham Lee
first release and then invalidate in deallocation?can i send argument with two arguments in selector?
First invalidate it, then release it (if you own it). Please clarify your last question. If you are asking whether you can call invalidate and release on the timer with only one call, the answer is no, unless you create your own convenience method that does these two things, and call that method.
Felixyz
can i send extra argument with @selector in NSTIMER?