I have an NSTimer that I stop when my application resigns, which I restart later when the application becomes active again. I did not understand that applicationWillResignActive will fire when my application starts (pretty obvious). So what happens, my NSTimer does not start correctly (when the application starts). My question is, is there a way to verify that the application resumes from inactive since it starts from it first?
- (void)applicationWillResignActive:(UIApplication *)application { // STOP CORE TIMER [[[self mapController] coreTimer] invalidate]; [[self mapController] setCoreTimer:nil]; }
.
- (void)applicationDidBecomeActive:(UIApplication *)application { // START CORE TIMER [[self mapController] setCoreTimer:[NSTimer scheduledTimerWithTimeInterval:ONE_SECOND target:[self mapController] selector:@selector(timerDisplay:) userInfo:nil repeats:YES]]; }
source share