backgroundTimeRemaining返回(35791394分钟)?
我在我的应用程序中使用beginBackgroundTaskWithExpirationHandler。 我了解后台应用程序完成工作的最大时间是10分钟,但是当我打印backgroundTimeRemaining的值时,我得到的是(35791394分钟)
NSTimeInterval timeLeft = [UIApplication sharedApplication].backgroundTimeRemaining; NSLog(@"Background time remaining2222: %.0f seconds (%d mins)", timeLeft, (int)timeLeft / 60);
这是正常的,还是看起来我做错了什么?
尝试这个:
NSLog(@"Background time remaining: %f seconds (%d mins)", timeLeft, (int)(timeLeft / 60));
尝试:
NSLog(@"Background time remaining2222: %.0f seconds (%d mins)", timeLeft, (int)(timeLeft / 60) );
在你的代码中,timeLeft正在被分割之前被更改为int,而不是之后。