Skip to content

Instantly share code, notes, and snippets.

@islandjoe
Created December 28, 2018 16:16
Show Gist options
  • Save islandjoe/fc8ce4f87997a691064b400e8db46c90 to your computer and use it in GitHub Desktop.
Save islandjoe/fc8ce4f87997a691064b400e8db46c90 to your computer and use it in GitHub Desktop.
Stop updating the location immediately as soon as the location manager gets a valid value.
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    let location = locations[locations.count - 1]
    if location.horizontalAccuracy > 0 {
      locationMgr.stopUpdatingLocation()
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment