Reputation: 6532
I need to find the NSTimer Invalidate Or not in if Condition....!
Because,NSTimer once Invalidate after another Invalidate is Crash the application...!
Any one help me with us....!
Thanks..!
Upvotes: 0
Views: 190
Reputation: 479
Store the timer in a variable and then check using
[timer isValid]
Upvotes: 1
Reputation: 12405
if([timerInstance isValid]){
//then invalidate
}else{
//do something else
}
Upvotes: 2
Reputation: 9977
If you store a timer in a member variable you should retain it. Because probably you created it using timerWithTimerInterval:
Anyhow. If your reference is valid you can check it using [myTimer isValid];
If you don't retain your timer, you should at least assign nil after invalidating it.
[myTimer invalidate];
myTimer = nil;
Upvotes: 3