Swift make protocol extension a Notification observer
Let's consider the following code: protocol A { func doA() } extension A { func registerForNotification() { NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardDidShow:"), name: UIKeyboardDidShowNotification, object: nil) } func keyboardDidShow(notification: NSNotification) { } } Now look at a UIViewController subclass that implements A: class AController: UIViewController, A { override func viewDidLoad() { super.viewDidLoad() self.registerForNotification() triggerKeyboard() } func triggerKeyboard() { // Some code that make key board appear } func doA() { } } But