Created
November 17, 2015 22:26
-
-
Save Igor-Palaguta/51a4f9ea978e122d3363 to your computer and use it in GitHub Desktop.
Override does not override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code prints A to console