How do I get the line below to compile?
UIView.setAnimationCurve(userInfo[UIKeyboardAnimationCurveUserInfoKey].integerValue)
Right now, it gives the compile error:
'NSNumber' is not a subtype of 'UIViewAnimationCurve'
Why does the compiler think userInfo[UIKeyboardAnimationCurveUserInfoKey].integerValue
is an NSNumber
when integerValue
is declared as an Int
?
class NSNumber : NSValue {
// ...
var integerValue: Int { get }`?
// ...
}
I've had similar issues with other enum types. What is the general solution?
UIView.setAnimationCurve(UIViewAnimationCurve.fromRaw((userInfo[UIKeyboardAnimationCurveUserInfoKey] as NSNumber).integerValue)!)
, syntactucally is okay, logically is not by all means. – Johnstonas NSNumber
. – Pepin