1

I'm trying to create a new override func when i got this error: Method does not override any method from it's superclass

I have already tried to delete the override part but that only gives me another error.

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

}
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
  • And the other error is...? Also, what is the type of the object this method is in? – Fogmeister Nov 01 '15 at 19:46
  • Different error message, but same problem as in http://stackoverflow.com/questions/28771896/overriding-method-with-selector-touchesbeganwithevent-has-incompatible-type. – Martin R Nov 01 '15 at 19:50

1 Answers1

5

The correct method signatures are:

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

}

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

}
joern
  • 27,354
  • 7
  • 90
  • 105