Search code examples
iosdoublenstimeinterval

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.


Solution

  • If the application is in the foreground, the time will be large as per documentation here.