Here is what I am trying to do:
class ViewController: UIViewController {
let screenRect: CGRect = UIScreen.mainScreen().bounds
let screenWidth = screenRect.w
The consts do not know about the other global consts because they are not initialized at this point. What you could do though is to use computed properties:
class ViewController: UIViewController {
var screenRect: CGRect { return UIScreen.mainScreen().bounds }
var screenWidth: CGFloat { return self.screenRect.origin.x }
}
This only works with vars, due to the nature of it. This should be considered depending on the use case. If you have to call it often, it might not be the wisest way in regards to performance.