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’m 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’s really no way to determine that. You could set variables to let you know when you’ve requested a location vs. when the delegate method has been called. What are trying to do that requires the last delegate method being called?