1
class ViewController: UIViewController {
var locationManager = CLLocationManager()
@IBOutlet weak var meuMapa: MKMapView!
override func viewDidLoad() {
// Ask for Authorisation from the User.
self.locationManager.requestAlwaysAuthorization()
// For use in foreground
self.locationManager.requestWhenInUseAuthorization()
if CLLocationManager.locationServicesEnabled() {
locationManager.delegate = self //ERRO: Cannot assign value of type ‘ViewController’to type CLLocationManager
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
locationManager.startUpdatingLocation()
How to get the user’s location Swift?