Last active
July 14, 2016 03:05
-
-
Save c0ming/ab07d39d8f4f13ccbc896be79836c906 to your computer and use it in GitHub Desktop.
Protocol Extensions Dispatch
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
//: Playground - noun: a place where people can play | |
import UIKit | |
protocol Delegate { | |
func foo(); | |
} | |
extension Delegate { | |
func foo() { | |
print("\(self)") | |
print("foo() in extension") | |
} | |
} | |
class VC: Delegate { | |
} | |
class SubVC: VC { | |
func foo() { // 为什么不是调用这里? | |
print("foo() in SubVC") | |
} | |
} | |
let vc:Delegate = SubVC() | |
vc.foo() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment