user6083214
user6083214

Reputation: 63

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?

Upvotes: 2

Views: 5148

Answers (1)

Midhun MP
Midhun MP

Reputation: 107201

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
{
}

Upvotes: 4

Related Questions