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];
這是偉大的工作但我有一種感覺,蘋果不會這樣,是最佳做法?