简体   繁体   中英

How to convert NSTimeInterval to seconds (for backgroundTimeRemaining)

I'm running test on measuring how much time left for background task time remaining. I have read several examples and saw that everyone doing it like:

UIApplication *app = [UIApplication sharedApplication];
double *bgTime = app.backgroundTimeRemaining;

NSLog(@"Background Time Remaining: %f", bgTime);  

But I get very long value like 1797693134862315708145274237317043567980705675258449965989...

I understand that [[UIApplication sharedApplication] backgroundTimeRemaining] is NSTimeInterval, but is there any way to convert this to just x seconds?

I have also tried this , but it won't work.

Any help would be appreciated.
Thank you.

Because NSTimeInterval is a float or double , but not a pointer. double *bgTime should be double bgTime .

如果应用程序位于前台,则根据此处的文档,时间将会很长。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM