I was having an issue with a subclass's method getting called that overrode a method, so I created a small app to test it. When the superclass calls a method that its subclass overrides, the superclass's version of the method still gets called instead of the subclass's version, which overrides the superclass's method and should be the method getting called.
Expected output: sub foo
Actual output: super foo
Superclass:
class ViewController: UIViewController
{
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent)
{
foo()
}
func foo()
{
println("super foo")
}
}
Subclass:
class SubclassViewController: ViewController
{
override func foo()
{
println("sub foo")
}
}
Make sure that the object's class is SubclassViewController. Otherwise, it will not have any knowledge of the method which is overriden by subclass
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With