Domo Domo - 11 days ago 7
iOS Question

Error Swift Method Does Not Override any Method from it's super class

override func supportedInterfaceOrientations() -> Int {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
} else {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
}


So I was working on a tutorial and I had completed it and when I updated to xcode 7 all my code got littered with bugs.

In the piece above I'm getting the error "method does not override any method from its super class" but when I remove override I get this error : Method 'supportedInterfaceOrientations()' with Objective-C selector 'supportedInterfaceOrientations' conflicts with method 'supportedInterfaceOrientations()' from superclass 'UIViewController' with the same Objective-C selector

I've been researching but I'm quite new to programming and a lot of the answers on here I don't understand well enough to apply to my situation.

Thank You

Answer

It no longer returns an Int. The new method signature wants a UIInterfaceOrientationMask returned.

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    if UIDevice.currentDevice().userInterfaceIdiom == .phone {
        return UIInterfaceOrientationMask.allButUpsideDown
    } else {
        return UIInterfaceOrientationMask.all
    }
}
Comments