2010-10-30 109 views
0

我需要在应用程序调用的背景中运行一个计时器,然后才能进入背景方法。我遇到了一些麻烦。当我进入背景时,它什么都不做。这是我的代码。是否有可能在后台运行计时器?

- (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

号这肯定是不行的。当应用程序在后台时,它被暂停并且不运行。

你想使用UILocalNotification类来做你正在说的。

See here.

或者看到这些类型的多任务话题here更广泛的讨论。

相关问题