silent lover 0 Light Poster

how to auto logout an apps when user did not touch the screen for at least 2 minutes?

i add this to AppDelegate.m :

- (void)sendEvent:(UIEvent *)event {
    [super sendEvent:event];

    // Only want to reset the timer on a Began touch or an Ended touch, to reduce the number of timer resets.
    NSSet *allTouches = [event allTouches];
    if ([allTouches count] > 0) {
        // allTouches count only ever seems to be 1, so anyObject works here.
        UITouchPhase phase = ((UITouch *)[allTouches anyObject]).phase;
        if (phase == UITouchPhaseBegan || phase == UITouchPhaseEnded)
            [self resetIdleTimer];
    }
}

- (void)resetIdleTimer {
    idleTimer = [[NSTimer scheduledTimerWithTimeInterval:maxIdleTime target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:NO] retain];
    if (idleTimer) {
        [idleTimer invalidate];
        [idleTimer release];
    }
}

- (void)idleTimerExceeded {
    NSLog(@"idle time exceeded");
}

but get error on line:

- (void)resetIdleTimer {
    idleTimer = [[NSTimer scheduledTimerWithTimeInterval:maxIdleTime target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:NO] retain];
    if (idleTimer) {
        [idleTimer invalidate];
        [idleTimer release];
    }
}

it said "use and undeclared identifier 'maxIdleTime'" on idleTimer = [[NSTimer scheduledTimerWithTimeInterval:maxIdleTime target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:NO] retain]; and "use and undeclared identifier 'idleTimer'" on

if (idleTimer) {
    [idleTimer invalidate];
    [idleTimer release];
}

i add this inside main.m :

int retVal = UIApplicationMain(argc, argv, @"AppDelegate", @"AppDelegate");

so the main.m become :

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        int retVal = UIApplicationMain(argc, argv, @"AppDelegate", @"AppDelegate");
    }
}

i though something was wrong so this inserted code error.
what code to enter so auto logout an apps when user did not touch the screen for at least 2 minutes? where i must put the code?
thank you daniweb friends.