I have this code below which runs when the keyboardWillShowNotification is called:
func keyboardWillShow(_ notification: Notification) {
//ERROR IN THE L
From the docs:
let UIKeyboardFrameEndUserInfoKey: String
Description
The key for an NSValue object containing a CGRect that identifies the end frame of the keyboard in screen coordinates
Your second key:
let UIKeyboardAnimationDurationUserInfoKey: String
Description The key for an NSNumber object containing a double that identifies the duration of the animation in seconds.
So you need to cast the first one to NSValue and the second one to NSNumber:
func keyboardWillShow(_ notification: Notification) {
print("keyboardWillShow")
guard let userInfo = notification.userInfo else { return }
keyboard = (userInfo[UIKeyboardFrameEndUserInfoKey] as! NSValue).cgRectValue
animaton = (userInfo[UIKeyboardAnimationDurationUserInfoKey] as! NSNumber).doubleValue
// your code
}