Q:

How can I get the dimensions of the view outside a function?

I am trying to access view.frame.size.height and view.frame.size.width outside a function, and I am not able to. Is there any workaround for this?
I tried doing this, but it did not work- 
 var screenBound = UIScreen.mainScreen().bounds
    var screenSize = screenBound.size
    var screenWidth = screenSize.width
    var screenHeight = screenSize.height

Xcode gave me an error- Instance member 'screenbound' cannot be used on type 'ViewController'
I can only use self.view.frame.size.height/.width inside a created function. But I want to use it outside a function. Thanks in advance.

A:

I'm not sure what exactly you're trying to do, but couldn't you just put this at the global level (i.e. above "class ViewController..."):
let screenWidth = UIScreen.mainScreen().bounds.size.width
 let screenHeight = UIScreen.mainScreen().bounds.size.height

Then you can access these anywhere in your project.

