ios - Why does logging backgroundTimeRemaining show a wrong/big number even though app was moved to background? -


i'm logging uiapplication.shared.backgroundtimeremaining number huge. it's 200 digits.

this how i'm logging it.

 os_log("lat: %f | long:  %f | remainingtime: %f ", log: log, type: .default, location.coordinate.latitude, location.coordinate.longitude, uiapplication.shared.backgroundtimeremaining) 

i thought there wrong format of logging tried placing breakpoint , printing still number logs same huge number. looked this question has fair explanation, if app in foreground time huge. still see number if there has been 5 minutes since i've moved app background.

a sample number remainingtime is:

179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000

entire code:

import uikit import corelocation import os.log import mapkit  class viewcontroller: uiviewcontroller, cllocationmanagerdelegate{      lazy var locationmanager : cllocationmanager = {         var manager = cllocationmanager()         manager.delegate = self          manager.desiredaccuracy = kcllocationaccuracybestfornavigation         manager.distancefilter = 1         manager.pauseslocationupdatesautomatically = true         manager.allowsbackgroundlocationupdates = true         manager.requestalwaysauthorization()         manager.startupdatinglocation()         return manager     }()      var lastlocation : cllocation?      var mapview : mkmapview?      let log = oslog(subsystem: "xyz.locationappsubsystem", category: "dumbo")      override func viewdidload() {         super.viewdidload()          if locationmanager.location != nil{          }else {              dispatchqueue.main.async {                 self.locationmanager.startupdatinglocation()             }          }         os_log("view loaded", log: log, type: .error)          mapview = mkmapview(frame: uiscreen.main.bounds)         mapview?.showsuserlocation = true         view.addsubview(mapview!)      }      func locationmanager(_ manager: cllocationmanager, didupdatelocations locations: [cllocation]) {          guard let location = locations.last else {             return         }         lastlocation = location         //        let date = date().description(with: locale.current)          os_log("lat: %{public}f | long:  %{private}f | remainingtime: %{public}f ", log: log, type: .default, location.coordinate.latitude, location.coordinate.longitude, uiapplication.shared.backgroundtimeremaining)      }      func locationmanagerdidpauselocationupdates(_ manager: cllocationmanager) {         os_log("locationmanager paused", log: log)          let location = lastlocation          os_log("lat: %{public}f | long:  %{private}f | remainingtime: %{public}f ", log: log, type: .default, (location?.coordinate.latitude)!, (location?.coordinate.longitude)!, uiapplication.shared.backgroundtimeremaining)       }      func locationmanager(_ manager: cllocationmanager, didexitregion region: clregion) {         os_log("region exited", log: log)     }      func createregion(location: cllocation) {          let radius = 3.0          let region = clcircularregion(center: location.coordinate, radius: radius, identifier: "didpauselocationupdates")         region.notifyonexit = true         region.notifyonentry = false          locationmanager.startmonitoring(for: region)     }      func locationmanager(_ manager: cllocationmanager, monitoringdidfailfor region: clregion?, witherror error: error) {         if region?.identifier == "didpauselocationupdates"{             os_log("main region failed created", log: log)         }else{             os_log("other regions checked ", log: log)         }     }   } 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -