backgroundTimeRemaining返回(35791394分钟)?

时间:2012-03-01 18:18:11

标签: ios ios5 ios4

我在我的应用程序中使用beginBackgroundTaskWithExpirationHandler。我理解为后台应用程序完成工作的最长时间是10分钟,但是当我打印backgroundTimeRemaining的值时得到的是(35791394分钟)

NSTimeInterval timeLeft = [UIApplication sharedApplication].backgroundTimeRemaining;
    NSLog(@"Background time remaining2222: %.0f seconds (%d mins)", timeLeft, (int)timeLeft / 60);

这是正常的,还是看起来我做错了什么?!

2 个答案:

答案 0 :(得分:2)

尝试:

NSLog(@"Background time remaining2222: %.0f seconds (%d mins)", timeLeft, (int)(timeLeft / 60) );

在你的代码中,timeLeft在分割之前被改为int,而不是之后。

答案 1 :(得分:1)

试试这个:

 NSLog(@"Background time remaining: %f seconds (%d mins)", timeLeft, (int)(timeLeft / 60));