在Swift 3中不推荐使用locationManager?

fra*_*ool 12 xcode core-location ios swift3 ios10

我已经下载了最新版本的XCode来测试iOs 10 Beta中的项目.当我打开它时,XCode问我是否要将我的项目转换为Swift 3.执行此操作后,出现了一个错误:

无法覆盖已标记为"不可用"的"locationManager":在iOS 7及更早版本中弃用的API在Swift中不可用

我的代码如下:

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

    currentUserLocation = newLocation
}
Run Code Online (Sandbox Code Playgroud)

是否有另一个"未弃用"功能来实现相同的结果?

谢谢!

Mar*_*ark 24

此方法替换了您正在使用的方法:

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

}
Run Code Online (Sandbox Code Playgroud)

在这里了解更多.