Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

locationManager deprecated in Swift 3?

I have downloaded the last version of XCode to test my project in iOs 10 Beta. When I have opened it, XCode asked me if I wanted to convert my project to Swift 3. After doing that, one error appeared :

Cannot override 'locationManager' which has been marked unavailable: APIs deprecated as of iOS 7 and earlier are unavailable in Swift

And my code is the following :

func locationManager(_ manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) {
    locationManager.stopUpdatingLocation()

    currentUserLocation = newLocation
}

Is there another "not deprecated" function to achieve the same result ?

Thanks!

like image 996
fraxool Avatar asked Jul 26 '16 13:07

fraxool


1 Answers

This method replaced the one you're using:

func locationManager(_ manager: CLLocationManager, 
                     didUpdateLocations locations: [CLLocation]) {

}

Find out more here.

like image 143
Mark Avatar answered Oct 07 '22 08:10

Mark