Created
January 20, 2016 08:20
-
-
Save ValCanBuild/a2d83681b534c18bb300 to your computer and use it in GitHub Desktop.
This file contains 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
// | |
// 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