iOS – backgroundTimeRemaining值没有显示预期的

我试图检查backgroundTimeRemaining的价值,但我得到了一个非常大的数字。 该属性的价值应该是对应的10分钟aprox,我已经在苹果的文档中看到 ,这样的价值是巨大的,当应用程序在前台。 但是,即使在后台,我也能获得很大的价值:

 - (void)applicationDidEnterBackground:(UIApplication *)application { bgTask = [application beginBackgroundTaskWithExpirationHandler:^{ [application endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; }]; // Background task NSTimeInterval timeRemaining = [UIApplication sharedApplication].backgroundTimeRemaining; NSLog(@"Background time remaining: %f seconds (%d mins)", timeRemaining, (int)(timeRemaining / 60)); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSTimeInterval timeRemaining = [UIApplication sharedApplication].backgroundTimeRemaining; NSLog(@"Background time remaining: %f seconds (%d mins)", timeRemaining, (int)(timeRemaining / 60)); // Perform task // Finished if (bgTask != UIBackgroundTaskInvalid) { [application endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; } }); // Start location manager if ([CLLocationManager locationServicesEnabled]) { [locationManager startUpdatingLocation]; } } 

我错过了什么? 提前致谢

从Xcode运行时,看门狗定时器被禁用。

我在运行时大部分都是明智的价值(即600),但我仍然偶尔会有奇怪的价值。