title: how to declare global variables in swift
body: <p>i created a UIButton programatically in Swift and i want to access the <strong>myBtn</strong> in whole class</p>
  
  <p>this is my code</p>
  
  <pre><code>import UIKit
  import Foundation
  
  class ViewController: UIViewController
  {
  
      @IBOutlet var btn: UIButton!
  
  
      @IBAction func btnPressed()
      {
          self.custum()
      }
  
      override func viewDidLoad()
      {
          super.viewDidLoad()
  
          let myBtn = UIButton.buttonWithType(UIButtonType.System) as UIButton
          myBtn.frame = CGRectMake(self.view.frame.size.width/2.5, self.view.frame.size.height/4, 100, 30)
          myBtn.setTitle("Button 1", forState: UIControlState.Normal)
          myBtn.addTarget(self, action: "btnPressed", forControlEvents: UIControlEvents.TouchUpInside)
          self.view.addSubview(myBtn)
          self.custum()
       }
  
      func custum()
      {
  
          UIView.animateWithDuration(1.0, animations:{
              let grow = CGAffineTransformMakeScale(1,1)
              let rotate = CGAffineTransformMakeRotation(10)
              myBtn.transform = CGAffineTransformConcat(grow, rotate) // i'm getting this error use of unresolved identifier 'myBtn'
          }) 
  
      }
  </code></pre>
  
  <p>i'm new to swift programming, please tell me if u know, thanks in advance.</p>