title: Returning JSON Data to a calling class in Swift
body: <p>I am looking to determine when a data download in another class has finished, and then return the downloaded data to the calling class. I have tried with completion handlers but this only tells me the data is downloaded and they reside in the DataManager class, how do I return to the calling class?</p>
  
  <p><strong>In FirstViewController.swift:</strong></p>
  
  <pre><code>func download(button: UIButton) {
  
      DataManager.getJSONData(url, completionHandler:DataManager.resultHandler)
  
  }
  </code></pre>
  
  <p><strong>In DataManager.swift:</strong></p>
  
  <pre><code>class func getJSONData(urlInput:String, completionHandler: ((NSDictionary!) -&gt; Void)?)
      {
  
          var url : NSURL! = NSURL(string:urlInput)
          var request: NSURLRequest = NSURLRequest(URL:url)
          let config = NSURLSessionConfiguration.defaultSessionConfiguration()
          let session = NSURLSession(configuration: config)
  
          let task : NSURLSessionDataTask = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in
              var error: AutoreleasingUnsafeMutablePointer&lt;NSError?&gt; = nil
  
              let jsonResult: NSDictionary! =  NSJSONSerialization.JSONObjectWithData(data, options: nil, error: error) as? NSDictionary!
  
              // then on complete I call the completionHandler...
              completionHandler?(jsonResult);
          });
          task.resume()
      }
  
  class func resultHandler(jsonResult:NSDictionary!)
      {
          NSLog("Data: %@ \n", jsonResult)
  
      }
  </code></pre>
  
  <p>How do I return jsonResult to the FirstViewController.swift, or alternatively, inform FirstViewController.swift that the download is complete?</p>