I am trying to stop the timer. My problem is when I try to stop the timer the value of timer is nil and it is not getting invalidated. if there any way to stop the timer except this ?
My code is like
timer is defined in header file – and also synthesized.
if([str_Message isEqualToString:ON] // if the command to start timer
{
if(!timer)
{
tmr_CallWebService = [[NSTimer scheduledTimerWithTimeInterval:Time_TracingInterval target:ClassTracing selector:@selector(startLocationTracing) userInfo:nil repeats:YES]retain];
}
//to stop timer
else if([str_Message isEqualToString:OFF])
{
if(timer)
{
[timer invalidate];
timer = nil;
}
Please help me out… thanks in advance
[str_Message isEqualToString:ON]should be like this[str_Message isEqualToString:@"ON"]. similarly for the comparison with OFF. Use@"OFF".