xcode locationManager 在 Swift 3 中已弃用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38591381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
locationManager deprecated in Swift 3?
提问by fraxool
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 :
我已经下载了最新版本的 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
无法覆盖已标记为不可用的“locationManager”:从 iOS 7 及更早版本开始弃用的 API 在 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!
谢谢!