views:

25

answers:

1

I need to have a timer running in the background that is called by the application did enter background method. I am having some trouble. When I enter background, it doesnt do anything. Here is my code.

- (void)applicationDidEnterBackground:(UIApplication *)application {

 bcheckingTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(bchecker) userInfo:nil repeats:YES];

}
- (void)bchecker {

 NSLog(@"Switch is on, will annoy");

}

+1  A: 

No. This will definitely not work. When the application is in the background, it is suspended and not running.

You want to use the UILocalNotification class to do what you are saying.

See here.

Or see a broader discussion on these types of multitasking topics here.

Brad