Created
November 16, 2016 13:03
-
-
Save SiarheiFedartsou/1b0f68c8c7ee93b85a91b1131ce5502b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Fooable { | |
func foo() -> String | |
} | |
extension Fooable where Self : UIViewController | |
{ | |
func foo() -> String | |
{ | |
return "foo" | |
} | |
} | |
protocol FooableView : Fooable {} | |
extension FooableView where Self : UIView | |
{ | |
func foo() -> String | |
{ | |
return "foo view" | |
} | |
} | |
extension UIView: FooableView {} | |
protocol FooableButton : Fooable {} | |
extension FooableButton where Self : UIButton | |
{ | |
func foo() -> String | |
{ | |
return "foo button" | |
} | |
} | |
extension UIButton: FooableButton {} | |
class ViewController: UIViewController, Fooable { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
print(self.foo()) | |
let v = UIView() | |
print(v.foo()) | |
let b = UIButton() | |
print(b.foo()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment