Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SiarheiFedartsou/1b0f68c8c7ee93b85a91b1131ce5502b to your computer and use it in GitHub Desktop.
Save SiarheiFedartsou/1b0f68c8c7ee93b85a91b1131ce5502b to your computer and use it in GitHub Desktop.
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