CaptainCOOLGUY CaptainCOOLGUY - 7 months ago 33
Swift Question

How to find keyboard height using Swift

let frame = (info[UIKeyboardFrameEndUserInfoKey] as NSValue) as CGRect

does not work. Anybody know why this does not function as expected?

Error: 'NSValue' not convertible to 'CGRect'

Keep in mind that something like:

let curve = (info[UIKeyboardAnimationCurveUserInfoKey] as NSValue) as UInt

works fine.

Edit: Even Apple documentation indicates this is a glitch because of the following comment in Cocoa for

// NSValue of CGRect

Edit2: The debugger defines it as an NSConcreteValue. How can I convert it to a CGRect?

let frame = (info[UIKeyboardFrameEndUserInfoKey] as NSValue).CGRectValue()