1
我试图让我的iOS应用程序在后台运行下去,(或位置采样和诊断有关的位置),我发现这个代码 -NSRunLoop后台任务有效
[self.locationManager stopUpdatingLocation];
self.timer = [NSTimer scheduledTimerWithTimeInterval:self.currentTimerTime target:self selector:@selector(checkLocation) userInfo:nil repeats:NO];
[[NSRunLoop currentRunLoop]addTimer:self.timer forMode:NSRunLoopCommonModes];
[[UIApplication sharedApplication]beginBackgroundTaskWithExpirationHandler:nil];
这是伟大的工作但我有一种感觉,苹果不会这样,是最佳做法?