【发布时间】:2015-12-22 06:01:01
【问题描述】:
我试图让我的 iOS 应用程序在后台永远运行,(或关于位置的位置采样和诊断)我找到了这段代码 -
[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];
这很好用,但我觉得苹果不喜欢这样,这是最佳做法吗?
【问题讨论】:
标签: ios location nsrunloop background-task