I'm trying to get keyboard notifications to work in my app but somehow I keep running into this error. This is my code:
override func viewWillAppear(_ animated: Bool) {
NotificationCenter.default.addObserver(self, selector: Selector(("keyboardDidShow:")), name: .UIKeyboardDidShow, object: nil)
NotificationCenter.default.addObserver(self, selector: Selector(("keyboardWillHide:")), name: .UIKeyboardWillHide, object: nil)
}
override func viewWillDisappear(_ animated: Bool) {
NotificationCenter.default.removeObserver(self)
}
func keyboardDidShow(notification : Notification)
{
print("keyboard shown")
if let keyboardSize = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.size
{
print(keyboardSize)
}
}
func keyboardWillHide(notification : Notification)
{
}
I honestly can't find where I'm going wrong. I keep getting the error as stated in the question statement.