【问题标题】:Ambiguous reference to member 'subscript' Swift 3对成员“下标”Swift 3 的模糊引用
【发布时间】:2016-10-02 15:14:02
【问题描述】:

在很多地方更新到 Swift 3 后,我都收到了这个错误,我已经更改了 ?和 !但是又出现了一个错误(Type [String : AnyObject]?Has not subscript members)

  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
        }
    }

【问题讨论】:

标签: swift3


【解决方案1】:

如果您添加了override,您将得到第一个提示,即该方法不会覆盖其超类中的任何方法

签名已更改为

func observeValue(forKeyPath keyPath: String?, 
                           of object: Any?, 
                              change: [NSKeyValueChangeKey : Any]?, 
                             context: UnsafeMutableRawPointer?)

【讨论】:

  • 感谢工作正常@vadian 你知道这个问题的答案吗:stackoverflow.com/questions/39673705/…
  • 不,我会删除所有 pod 并重新创建它们。
  • 谢谢我已经这样做了,但是所有文件都在我创建的文件夹中 xcode
猜你喜欢
  • 2017-02-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多