Skip to content

Instantly share code, notes, and snippets.

@ValCanBuild
Created January 20, 2016 08:20
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 ValCanBuild/a2d83681b534c18bb300 to your computer and use it in GitHub Desktop.
Save ValCanBuild/a2d83681b534c18bb300 to your computer and use it in GitHub Desktop.
//
// ControllerAware Protocol
// Shows how to have view controller instances which implement
// a specific protocol have it's method called on viewDidLoad.
import UIKit
protocol ControllerAware {
func onViewDidLoad()
}
class BaseViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
if let controllerAwareSelf = self as? ControllerAware {
controllerAwareSelf.onViewDidLoad()
}
}
}
class MyCustomVC: BaseViewController, ControllerAware {
func onViewDidLoad() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment