2010-10-30 101 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更廣泛的討論。

相關問題