gpt4 book ai didi

ios - 'locationManager(_:didUpdateLocations:)' 的参数具有与协议(protocol) 'CLLocationManagerDelegate' 预期不同的可选性

转载 作者:搜寻专家 更新时间:2023-10-31 23:01:15 24 4
gpt4 key购买 nike

我在我的 View Controller 中实现了CLLocationManagerDelegate,但我收到了以下警告

Parameters of 'locationManager(_:didUpdateLocations:)' have different optionality than expected by protocol 'CLLocationManagerDelegate'

Parameters of 'locationManager(_:didFailWithError:)' have different optionality than expected by protocol 'CLLocationManagerDelegate'

Parameter of 'locationManager(_:didChangeAuthorizationStatus:)' has different optionality than expected by protocol 'CLLocationManagerDelegate'

由此我明白了“参数的可选性(变量是否可选)与原始协议(protocol)方法定义中的不同"

但我找不到原件和我随身携带的任何区别。

在这里

在协议(protocol)定义中

optional public func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation])

optional public func locationManager(manager: CLLocationManager, didFailWithError error: NSError)

optional public func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus)

在我的协议(protocol)实现中

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

func locationManager(manager: CLLocationManager,
didFailWithError error: NSError)

func locationManager(manager: CLLocationManager,
didChangeAuthorizationStatus status: CLAuthorizationStatus)

我的xcode版本是7.1.1

那么谁能解释一下为什么会弹出警告?

最佳答案

重新启动 xcode 解决了问题......有时事情很奇怪

关于ios - 'locationManager(_:didUpdateLocations:)' 的参数具有与协议(protocol) 'CLLocationManagerDelegate' 预期不同的可选性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34747618/

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