Swift 3 中弃用了 locationManager?

locationManager deprecated in Swift 3?

我已经下载了最新版本的 XCode 来测试我在 iOs 10 Beta 中的项目。当我打开它时,XCode 问我是否要将我的项目转换为 Swift 3。这样做之后,出现了一个错误:

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

我的代码如下:

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

    currentUserLocation = newLocation
}

是否有另一个 "not deprecated" 函数可以达到相同的结果?

谢谢!

此方法取代了您正在使用的方法:

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

}

了解更多 here