I am trying to set an instance constant/variable set in Swift an directly reuse it to set another instance constant/variable
This code does not work:
let stLoginViewYDeltaWhenKeyboardIsShowing = DEVICE_HAS_IPHONE4_SCREEN_SIZE ? 0.0 : -16.0
let loginViewYDeltaWhenKeyboardIsShowing = IS_ST_TARGET ? stLoginViewYDeltaWhenKeyboardIsShowing : 30.0
It gives an error:
'LoginViewController.Type' does not have a member named 'stLoginViewYDeltaWhenKeyboardIsShowing'
This code does compile but does not look that good:
static let stLoginViewYDeltaWhenKeyboardIsShowing = DEVICE_HAS_IPHONE4_SCREEN_SIZE ? 0.0 : -16.0
let loginViewYDeltaWhenKeyboardIsShowing = IS_ST_TARGET ? LoginViewController.stLoginViewYDeltaWhenKeyboardIsShowing : 30.0
Any better approaches? In Objective-C both #define
and a normal variable would have worked.