0

In swift, I'm trying to pull some info out of a keyboard notification:

fun gotKeyboardShowNotification(notification:NSNotification) {
        NSLog("gotKeyboardShowNotification: \(notification)")
        let theUserInfo = notification.userInfo!
        let theFrameBegin = theUserInfo[UIKeyboardFrameBeginUserInfoKey]
        let theBeginObject = theFrameBegin!
        let theBeginRect = theBeginObject as NSRect

The log shows notification includes UIKeyboardFrameBeginUserInfoKey = "NSRect: {{0, 736}, {414, 271}}";

but I can't seem to get at the rect:

theUserInfo is type [NSObject:AnyObject]
theFrameBegin is type AnyObject?
theBeginObject is type NSConcreteValue*
theBeginRect is type NSConcreteValue*

I tried various casting and constructs but haven't figured out how to get a CGRect out of this thing!

lepton
  • 51
  • 6
  • All the variables look the same, they all begin with "the". Generally looking the same is not a good thing. – zaph Oct 05 '15 at 14:28
  • I typically start symbols in local scope with "the" (theLocal), arguments with "a" (aArgument), constants with "k" (kConstant) etc. Works for me. BTW this code is verbose to expose the intermediate types. (and I got my answer in the duplicate) – lepton Oct 05 '15 at 17:08

0 Answers0