在将Swift 3更新很多地方后,出现此错误,我已经更改了?和 !但是出现了另一个错误(类型[String:AnyObject]?没有下标成员)
func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutableRawPointer) {
if !didFindMyLocation {
let myLocation: CLLocation = change? [NSKeyValueChangeNewKey] as! CLLocation //Ambiguous reference to member 'subscript'
viewMap.camera = GMSCameraPosition.camera(withTarget: myLocation.coordinate, zoom: 10.0)
viewMap.settings.myLocationButton = true
didFindMyLocation = true
}
}
如果添加override
了该方法,您将得到第一个提示,即该方法不会覆盖其超类中的任何方法。
签名已更改为
func observeValue(forKeyPath keyPath: String?,
of object: Any?,
change: [NSKeyValueChangeKey : Any]?,
context: UnsafeMutableRawPointer?)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句