MapKit and Core Location 路 Introduction | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9236-mapkit-and-core-location/lessons/10

Hi *,

I鈥檓 facing a problem with the requestLocation() call on iOS 12.

Normally one requestLocation() call leads to one event for the locationManager( didUpdateLocations) delegate method. Unfortunately, from time to time there are several events generated, thus the delegate method is called several times.

Is there a way to figure out the very last call of the delegate method?

The code with requestLocation() call looks like:

@IBAction func getPosition(_ sender: UIButton) {
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
locationManager.activityType = .other
locationManager.requestLocation()
}

The locationManager variable is created by
let locationManager = CLLocationManager()
at the very beginning of the ViewController.

Thanks in advance
Peter

There鈥檚 really no way to determine that. You could set variables to let you know when you鈥檝e requested a location vs. when the delegate method has been called. What are trying to do that requires the last delegate method being called?