方法不覆盖任何方法从它的超
问题描述:
我试图创建一个新的覆盖FUNC当我得到这个错误:从它的父类方法不覆盖任何方法方法不覆盖任何方法从它的超
我已经尝试删除重写部分但那只会给我另一个错误。
override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) {
let touch : UITouch! = touches.anyObject() as! UITouch
location = touch.locationInView(self.view)
person.center = location
}
override func touchesMoved(touches: NSSet!, withEvent event: UIEvent!) {
let touch : UITouch! = touches.anyObject() as! UITouch
location = touch.locationInView(self.view)
person.center = location
}
答
正确的方法签名是:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
}
而另一个错误是...?另外,这个方法所用的对象的类型是什么? – Fogmeister
不同的错误消息,但在http://stackoverflow.com/questions/28771896/overrideding-method-with-selector-touchesbeganwithevent-has-incompatible-type相同的问题。 –