title: How to store response from dataTaskWithUrl in other variable?
body: <p>I am trying to use completion handler to store the data outside of dataTaskWithUrl to use with other methods.</p>
  
  <p>This is my code :</p>
  
  <pre><code>import UIKit
  import XCPlayground
  
  XCPSetExecutionShouldContinueIndefinitely(true)
  
  let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
  var jsonData : NSDictionary
  let urlString = "&lt;my_rest_api&gt;"
  session.dataTaskWithURL(NSURL(string: urlString)!, completionHandler: {
      (taskData, taskResponse, taskError) -&gt; Void in
      var jsonReadError: NSError?
      var jsonResult = try! NSJSONSerialization.JSONObjectWithData(taskData!, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
  
      var resp=jsonResult["response"] as! String
      var data: NSData = resp.dataUsingEncoding(NSUTF8StringEncoding)!
      var jsonResultNested = try! NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers) as! NSArray
      dispatch_async(dispatch_get_main_queue(), {
          jsonData = jsonResultNested[0] as! NSDictionary
      })
  
  }).resume()
  </code></pre>
  
  <p>When I print <code>jsonData</code> outside, it says </p>
  
  <blockquote>
    <p>error: variable 'jsonData' used before being initialized</p>
  </blockquote>
  
  <p>How to do this with completion handler?</p>