我正在测试剩余的后台任务时间剩余时间。我已经阅读了几个例子,看到每个人都这样做:
UIApplication *app = [UIApplication sharedApplication];
double *bgTime = app.backgroundTimeRemaining;
NSLog(@"Background Time Remaining: %f", bgTime);
但我得到很长的价值,如1797693134862315708145274237317043567980705675258449965989 ......
我知道[[UIApplication sharedApplication] backgroundTimeRemaining]是NSTimeInterval,但有没有办法将其转换为x秒?
我也尝试了this,但它不起作用。
任何帮助将不胜感激 谢谢。
答案 0 :(得分:2)
因为NSTimeInterval
是float
或double
,而不是指针。 double *bgTime
应为double bgTime
。
答案 1 :(得分:2)
如果应用程序位于前台,则文档here的时间会很长。