user6083214 user6083214 - 3 months ago 35
iOS Question

Override func Error! Method does not override any method from its superclass

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

override func supportedInterfaceOrientations() -> Int {

Here I have an error. It says

Method does not override any method from its superclass.

This comes multiple times, I can't fix it.

Do you know something about it?


The error is coming because your method signature is different than the actual ones. You should use the exact method signature for overriding (Either you should use auto-complete feature provided in Xcode or refer the documentation)

Touches Began:

override func touchesBegan(_ touches: Set<UITouch>, 
         with event: UIEvent?)

In Swift 3 supportedInterfaceOrientations is no longer a method, it's a computed property, so it's signature becomes:

override var supportedInterfaceOrientations : UIInterfaceOrientationMask