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 *)applicati开发者_开发问答on {
bcheckingTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(bchecker) userInfo:nil repeats:YES];
}
- (void)bchecker {
NSLog(@"Switch is on, will annoy");
}
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.
精彩评论