Skip to content

Instantly share code, notes, and snippets.

@toshi0383
Created July 25, 2015 07:07
Show Gist options
  • Select an option

  • Save toshi0383/1e27058fa7363a7ce0f3 to your computer and use it in GitHub Desktop.

Select an option

Save toshi0383/1e27058fa7363a7ce0f3 to your computer and use it in GitHub Desktop.
さっきのprotocol extensionをsuperclass的に扱うやつBAD ACCESSになった。 #cswift #CodePiece
import UIKit
protocol CustomViewControllerType {
func hello()
}
extension CustomViewControllerType {
func hello() {
print("hello")
}
}
extension ViewController : CustomViewControllerType {
func hello() {
let a = self as CustomViewControllerType
a.hello()
print("yellow")
}
}
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
hello()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment