swiftlocationmapkittheorycllocation

When does didUpdateLocation get called?


Let's say you want to focus your MapView on the current location, then you write some code in didUpdateLocation which processes the current location coordinates.

But if you don't call requestLocation or startUpdatingLocaion on your CLLocationManager object, the method never gets called. Is that correct?

But wether you call requestLocation or startUpdatingLocation if you look on your MapView the blue dot which shows your location moves (e.g. you simulate movement) but didUpdateLocation won't get called automatically.

I am trying to understand why they made a delegate method when you kind of have to call it yourself.


Solution

  • You have to call the startUpdatingLocation ONCE and the didUpdateLocation delegate method will be called every time when the location changes. This is very different compared to what you say.