tags:

views:

26

answers:

1

Hi Every One ,

I want to create on slide show in my iphone application which open if the user don't touch the screen for 30 second , for that i have made on method which reset the time when user touch the screen .

I have used nstimer class to handle timer event .

my problem is that even if invalidating the timer the event has been fire after the time interval my reset timer method is as per below

-(void) resetTimer {

    if(timerForScreenSaver != nil)
    {   
        timerForScreenSaver = nil;
        [timerForScreenSaver invalidate];
        NSLog(@"timer is invalidate %@ ",timerForScreenSaver);
    }

    timerForScreenSaver = [NSTimer scheduledTimerWithTimeInterval:15.0 target:self selector:@selector(showScreenSaver) userInfo:nil repeats:NO];

    NSLog(@"timer is set");
}

can any one help me to reset the timer .

Thanks and Regard
     Kunal Patel

+1  A: 

Swap the following two lines:

timerForScreenSaver = nil;
[timerForScreenSaver invalidate];

You make your timer nil so invalidating has no effect

Vladimir
i have already try this thing .. but it crash the application
kunal patel
may be you invalidate your timer more than once for some reason? With what error your application crashes?
Vladimir