func locationManager didUpdateLocation doesn't work

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)

You need to tell the location manager to whom it should be delivering location updates.


userLocationMang.delegate = self

I have the same problem, even after assigning the delegate. Neither locationManagerDidChangeAuthorization, didUpdateLocations, nor didFailWithError are ever called on Swift 6.

func locationManager didUpdateLocation doesn't work
 
 
Q