Skip to content

Instantly share code, notes, and snippets.

@Igor-Palaguta
Created November 17, 2015 22:26
Show Gist options
  • Save Igor-Palaguta/51a4f9ea978e122d3363 to your computer and use it in GitHub Desktop.
Save Igor-Palaguta/51a4f9ea978e122d3363 to your computer and use it in GitHub Desktop.
Override does not override
protocol CDelegate: class {
func f()
}
class C {
weak var delegate: CDelegate?
func g() {
self.delegate?.f()
}
}
class A: NSObject, CDelegate {
func f() {
print("A")
}
}
class B: A {
}
extension B {
override func f() {
print("B")
}
}
let b = B()
let c = C()
c.delegate = b
c.g()
@Igor-Palaguta
Copy link
Author

This code prints A to console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment