'locationManager(_:didUpdateLocations:)' 的参数与协议 'CLLocationManagerDelegate' 预期的可选性不同
Parameters of 'locationManager(_:didUpdateLocations:)' has different optionality than expected by protocol 'CLLocationManagerDelegate'
我已经在我的 viewcontroller 中实现了 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'
由此我明白了
“
参数的可选性(变量是否可选)与原始协议方法定义中的不同
“
但是我没发现原件和我带的有什么区别。
在这里
在协议定义中
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 解决了问题...有时事情很奇怪
我已经在我的 viewcontroller 中实现了 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'
由此我明白了 “ 参数的可选性(变量是否可选)与原始协议方法定义中的不同 “
但是我没发现原件和我带的有什么区别。
在这里
在协议定义中
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 解决了问题...有时事情很奇怪