Swift 3中locationManager已过时?

12

我下载了最新版本的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
}

是否有另一个“未被弃用”的函数可以实现相同的结果?

谢谢!

1个回答

24

这种方法替换了你当前使用的方法:

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

}

了解更多信息,请单击此处


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接