开发者

Is it possible to have a timer running in background?

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜