title: Setting an image as a global variable (in Swift)
body: <p>I am trying to set an image as a global variable. To explain it a little bit more: I have two view controllers. Viewcontroller1 is a menu and view controller 2 is a view controller with an image view. </p>
  
  <p>What I would like to accomplish is to download an image in the first view controller, setting that image as a global variable and using that image in view controller2. </p>
  
  <p>So far, I have this: </p>
  
  <pre><code>import UIKit
  
  var globalImage = [String: UIImage]()
  
  
  class ViewController: UIViewController {
  
      // this function hides the statusbar
      override func prefersStatusBarHidden() -&gt; Bool {
          return true
      }
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
          // variables for accessing web images
          let url = NSURL(string: "http://www.fteunen.com/app/overLay.png")
          let urlRequest = NSURLRequest(URL: url!)
          NSURLConnection.sendAsynchronousRequest(urlRequest, queue: NSOperationQueue.mainQueue(), completionHandler: {
              response, data, error in
  
              if error != nil {
  
                  println("Something happened i guess, not good!!")
              } else {
                  //let image = UIImage(data: data)
                  globalImage = UIImage(data: data)
              }
  
          })
  
  
  
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  
  }
  </code></pre>
  
  <p>But unfortunately, this failed and at the line <code>globalImage = UIImage(data: data)</code> it gives an error saying *missing argument for parameter 'inBundle' in Call *</p>
  
  <p>So, is there just a syntax error somewhere? Or is there another way of doing this? Is my idea even going to work?</p>
  
  <p>Thanks in advance for your ideas and solutions! </p>