nulo encontrado inesperadamente al desenvolver un valor opcional keyboardWillShow

Tengo este código a continuación que se ejecuta cuando se llama a keyboardWillShowNotification:

func keyboardWillShow(_ notification: Notification) {
    //ERROR IN THE LINE BELOW            
    keyboard = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as AnyObject).cgRectValue
    animaton = (notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] as AnyObject).doubleValue

    UIView.animate(withDuration: 0.4, animations: { () -> Void in
       self.scrollView.frame.size.height = self.scrollViewHeight - self.keyboard.height
    }) 
}

Recibo un error en la segunda línea que dice:unexpectedly found nil while unwrapping an Optional value. Básicamente, cada vez que hago clic en uno de los campos de texto, se llamará a esta notificación para el teclado y el código enkeyboardWillShow correrá. Se que pongoif...let declaraciones pero quiero saber por qué me estoy volviendo nulo por esto.

Tampoco estoy seguro de cómo obtengo este error o cómo lo depuro. ¿Es porque lo estoy ejecutando desde el simulador?

Esto es lo que imprime la notificación. UserInfo:

Opcional ([AnyHashable ("UIKeyboardFrameEndUserInfoKey"): NSRect: {{0, 315}, {320, 253}}, AnyHashable ("UIKeyboardIsLocalUserInfoKey"): 1, AnyHashable ("UIKeyboardBoundsUserInfoKey"): 0, 0Rect: {0} , {320, 253}}, AnyHashable ("UIKeyboardAnimationCurveUserInfoKey"): 7, AnyHashable ("UIKeyboardCenterBeginUserInfoKey"): NSPoint: {160, 694.5}, AnyHashable ("UIKeyboardCenterEndUserInfoKey"), AnyHashable (}: NSPoint:} UIKeyboardFrameBeginUserInfoKey "): NSRect: {{0, 568}, {320, 253}}, AnyHashable (" UIKeyboardAnimationDurationUserInfoKey "): 0.25])

Respuestas a la pregunta(2)

Su respuesta a la pregunta