Ios 参数';位置管理器(didUpdateLocations:)&x27;具有不同于协议预期的可选性';CLLocationManagerDelegate';

Ios 参数';位置管理器(didUpdateLocations:)&x27;具有不同于协议预期的可选性';CLLocationManagerDelegate';,ios,xcode,swift,cllocationmanager,optional-parameters,Ios,Xcode,Swift,Cllocationmanager,Optional Parameters,我已在我的viewcontroller中实现了CLLocationManagerDelegate,并收到以下警告 “locationManager(u:didUpdateLocations:)”的参数具有不同的 协议“CLLocationManagerDelegate”的可选性超出预期 “locationManager(u:didFailWithError:)”的参数具有不同的 协议“CLLocationManagerDelegate”的可选性超出预期 “locationManager(\uux

我已在我的viewcontroller中实现了CLLocationManagerDelegate,并收到以下警告

“locationManager(u:didUpdateLocations:)”的参数具有不同的 协议“CLLocationManagerDelegate”的可选性超出预期

“locationManager(u:didFailWithError:)”的参数具有不同的 协议“CLLocationManagerDelegate”的可选性超出预期

“locationManager(\uux0:didChangeAuthorizationStatus:)”的参数已被删除 不同于协议预期的可选性 “CLLocationManagerDelegate”

从这一点我明白了什么 " 参数的可选性(无论变量是否可选)与原始协议方法定义中的不同 "

但是我找不到原版和我随身携带的有什么区别

给你

在协议定义中

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)
在我执行协议的过程中

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解决了问题…有时情况很奇怪

尝试通过键入
loc
并使用代码完成来重新实现功能。如果在代码完成中没有出现警告,则协议实现有问题。您是否导入了CoreLocation?是的,我导入了它,并且该方法在
CLLocationManagerDelegate
上也可用,看起来很正常。您是否也在视图控制器的
行中添加了
CLLocationManagerDelegate