Monday, 15 March 2010

types - Swift: NSNumber is not a subtype of UIViewAnimationCurve -



types - Swift: NSNumber is not a subtype of UIViewAnimationCurve -

how line below compile?

uiview.setanimationcurve(userinfo[uikeyboardanimationcurveuserinfokey].integervalue)

right now, gives compile error:

'nsnumber' not subtype of 'uiviewanimationcurve'

why compiler think userinfo[uikeyboardanimationcurveuserinfokey].integervalue nsnumber when integervalue declared int?

class nsnumber : nsvalue { // ... var integervalue: int { }`? // ... }

i've had similar issues other enum types. general solution?

uiview.setanimationcurve(uiviewanimationcurve.fromraw(userinfo[uikeyboardanimationcurveuserinfokey].integervalue)!)

read more: swift enumerations & fromraw()

update

based on this reply how utilize default ios7 uianimation curve, utilize new block-based animation method, + animatewithduration:delay:options:animations:completion:, , uiviewanimationoptions so:

let options = uiviewanimationoptions(uint((userinfo[uikeyboardanimationcurveuserinfokey] nsnumber).integervalue << 16))

types casting enums swift nsnumber

No comments:

Post a Comment