Tutorial 3: Question about stopping location manager after accuracy levels out

On the book, on page 53, it says “When the last couple of coordinates you received aren’t increasing in
accuracy then this is probably as good as it’s going to get and you should let the
radio power down.”. Then the code follows as below…

// 3
if location == nil || location!.horizontalAccuracy > newLocation.horizontalAccuracy {
// 4
lastLocationError = nil
location = newLocation
// 5
if newLocation.horizontalAccuracy <= locationManager.desiredAccuracy {
print(“*** We’re done!”)

This code will stop location manager when it eventually reaches the desiredAccuracy.

But say, after a while the accuracy levels out, but never reaches the desiredAccuracy. Then the stopLocationManager will never be called from what I understand.
So I don’t see this accomplishing what is mentioned at the beginning of this post.

Am I missing something?


  • Sekar

Keep on reading. :smiley: You will also add a timeout that stops the location manager after a few seconds.

ok…:grinning: I will wait till I finish the tutorial :slight_smile: