gpt4 book ai didi

swift 2.0 : Override error message for superclass

转载 作者:可可西里 更新时间:2023-11-01 00:14:26 25 4
gpt4 key购买 nike

切换到 Swift 2.0 之后

  override public func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)  {
userInteractionBegan(touches.first as! UITouch)
}

产生错误信息:

Method class does not override any method from its superclass

我不知道为什么 override 不再覆盖了!

最佳答案

在 Swift 2 中,touchesBegan 发生了变化。方法。现在第一个参数是Set<UITouch>而不是 NSObject .所以 Swift 告诉你你试图覆盖一个不存在的方法。使用 Set<UITouch>相反:

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
^^^^^^^
}

关于 swift 2.0 : Override error message for superclass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32176822/

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