Last active
May 23, 2020 14:25
-
-
Save alexnikol/bfba1b2f9cac2523b6b6f0b9a13ebdb1 to your computer and use it in GitHub Desktop.
CLLocationManager Set up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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