I can't get the function didUpdateLocations to work; I can't get swift to execute the code within it.
override func viewDidLoad() {
super.viewDidLoad()
userLocationMang.desiredAccuracy = kCLLocationAccuracyBest
userLocationMang.requestWhenInUseAuthorization()
print ("request authorization")
userLocationMang.startUpdatingLocation()
print ("fetching location")
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
print ("error")
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print ("location updated")
let userCoord = locations[locations.count - 1]
let userLan = userCoord.coordinate.latitude
let userLon = userCoord.coordinate.longitude
let userLanLon = userCoord.coordinate
print (userLanLon)
print ("get coordinate")
let userCoord2D = CLLocationCoordinate2D(latitude: userLon, longitude: userLan)
print (userCoord2D)