I have the following code:
let userInfo = notification.userInfo
let animationCurve = userInfo?[UIKeyboardAnimationCurveUserInfoKey] as UIViewAnimationCurve
let animationDuration = userInfo?[UIKeyboardAnimationDurationUserInfoKey] as NSTimeInterval
let keyboardFrame = userInfo?[UIKeyboardFrameEndUserInfoKey] as CGRect
userInfo
is a [NSObject: AnyObject]?
dictionary and the UIKeyboardAnimationCurveUserInfoKey
keys are all NSString!
s. Now I want to get some elements from this dictionary. But it seems not all items I want to use inherit from AnyObject
. UIViewAnimationCurve
is an enum
and CGRect
is a struct
.
I am translating this code from Objective-C, where the following syntax is used:
[[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&animationCurve];
Now I want to know how I can get these elements from the dictionary without using (unsafe) pointers.