Created
February 2, 2017 14:00
-
-
Save tjeerdintveen/4293a91f1f680eec186ead24f58c00eb to your computer and use it in GitHub Desktop.
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
import UIKit | |
extension UIView: Showable { | |
} | |
protocol Showable { | |
func layout() | |
func animate() // Remove me to see the change | |
} | |
extension Showable where Self: UIView { | |
func layout() { | |
print("layout called from VIEW") | |
animate() | |
} | |
func animate() { | |
print("animate called from VIEW") | |
} | |
} | |
extension Showable where Self: UIButton { | |
func layout() { | |
print("layout called from BUTTON") | |
animate() | |
} | |
func animate() { | |
print("animate called from BUTTON") | |
} | |
} | |
let view = UIView() | |
view.layout() | |
let btn = UIButton() | |
btn.layout() // This one changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment