0
调用两次在“-applicationDidEnterBackground”的方法我beginBackgroundTaskWithExpirationHandler代码块,我的NSTimer实现如下:选择方法beginBackgroundTaskWithExpirationHandler
UIBackgroundTaskIdentifier taskId = [application beginBackgroundTaskWithExpirationHandler:^{
timer = [NSTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(print:) userInfo:nil repeats:NO];
}];
而且Eventhough其repeats:NO
,“print'method的选择是叫两次,我可以通过NSLog
看到。
这个计时器并没有从applicationDidEnterBackground
以外的任何地方被调用。
嗯..是的,你是对的。我不知道我是什么。所以,我jst用'print'方法的代码块去除了定时器,并且它的行为方式相同。所以,这个行为与计时器有关。但似乎'beginBackgroundTaskWithExpirationHandler'的代码块正在执行两次。其实,我在我的项目中使用CLLocation管理器,可以这样做吗? – lasata
我不能确定没有你的代码。发布你做了什么,也许我可以帮助。 –