Trying to add keyboard observers in swift and getting error
NSNotificationcenter does not have a member names 'defaultCenter"
using
NSNotificationCenter().defaultCenter().addObserver(self, selector: Selector("keyboardWillAppear"), name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter().defaultCenter().addObserver(self, selector: Selector("keyboardWillHide"), name: UIKeyboardWillHideNotification, object: nil)
As advised from the following NSNotificationCenter addObserver in Swift Swift: Keyboard Observer via NSNotificationCenter doesn't work
If I remove defaultCenter
I don't get the error but, also no observing of the keyboard
NSNotificationCenter().addObserver(self, selector: Selector("keyboardWillAppear"), name: UIKeyboardWillShowNotification, object: nil)
NSNotificationCenter().addObserver(self, selector: Selector("keyboardWillHide"), name: UIKeyboardWillHideNotification, object: nil)