Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Last active May 23, 2020 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexnikol/bfba1b2f9cac2523b6b6f0b9a13ebdb1 to your computer and use it in GitHub Desktop.
Save alexnikol/bfba1b2f9cac2523b6b6f0b9a13ebdb1 to your computer and use it in GitHub Desktop.
CLLocationManager Set up
import UIKit
import CoreLocation
class ViewController: UIViewController {
private let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self //Set our controller as delegate
locationManager.desiredAccuracy = kCLLocationAccuracyBest //Switch location manager in best accuracy mode
locationManager.requestAlwaysAuthorization() //Ask user permissions about location detection
locationManager.startUpdatingLocation() //Start user location detection
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment