Backgroundtimeremaining Returns (35791394 Mins)

backgroundTimeRemaining returns (35791394 mins)?

Try this:

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

How to convert NSTimeInterval to seconds (for backgroundTimeRemaining)

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

What is this big number for backgroundTimeRemaining

As your new to ios coding, a little tip:
Hold ALT and click on backgroundTimeRemaining. It tell's you it returns an NSTimeInterval which is a double, so using %f is not the problem.

If you click the bottom blue link of the popup it'll open the docs and you'll see it says that this figure will be very large if the app isn't actually in the background.

So I'm guessing this is your issue, that your app is in the foreground when the NSLog is printed.



Related Topics



Leave a reply



Submit