Skip to content

Instantly share code, notes, and snippets.

@c0ming
Last active July 14, 2016 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c0ming/ab07d39d8f4f13ccbc896be79836c906 to your computer and use it in GitHub Desktop.
Save c0ming/ab07d39d8f4f13ccbc896be79836c906 to your computer and use it in GitHub Desktop.
Protocol Extensions Dispatch
//: 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