Swift 2.0:超类重写错误消息
切换到Swift 2.0后Swift 2.0:超类重写错误消息,swift,swift2,overriding,Swift,Swift2,Overriding,切换到Swift 2.0后 override public func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { userInteractionBegan(touches.first as! UITouch) } override public func touchsbegind(touchs:Set,withEvent-event:UIEvent){ 用户交互开始(touch.
override public func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
userInteractionBegan(touches.first as! UITouch)
}
override public func touchsbegind(touchs:Set,withEvent-event:UIEvent){
用户交互开始(touch.first as!UITouch)
}
生成一条错误消息:
方法类不重写其超类中的任何方法
我不知道为什么覆盖不再覆盖了 在swift中,方法签名更改为更“快速”。这是您应该使用的新方法签名:
override public func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
override public func touchsbegind(touchs:Set,withEvent-event:UIEvent?){
}
在Swift 2中,触摸开始
方法有变化。现在,第一个参数是Set
,而不是NSObject
。斯威夫特告诉你,你试图覆盖一个不存在的方法。改用设置:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
^^^^^^^
}
覆盖函数触摸开始(触摸:设置,withEvent事件:UIEvent?){
^^^^^^^
}