gpt4 book ai didi

ios - locationManager 在 Swift 3 中被弃用了吗?

转载 作者:技术小花猫 更新时间:2023-10-29 10:32:34 25 4
gpt4 key购买 nike

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

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

谢谢!

最佳答案

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

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

}

了解更多 here .

关于ios - locationManager 在 Swift 3 中被弃用了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38591381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com