title: Why is DataTaskWithRequest is being called last?
body: <p>I have to make an application that recovers data in an API, for that I use <code>NSURLSession.sharedSession</code> and <code>dataTaskWithRequest</code> with my request.</p>
  
  <p>I managed to recover all the informations but I cannot understand why <code>dataTaskWithRequest</code> is called last.</p>
  
  <pre><code>func my_connection(login: NSString, password: NSString) -&gt; Void {
  let request: NSMutableURLRequest = create_request(login, password: password)
  let session = NSURLSession.sharedSession()
  print("test1")
  let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) -&gt; Void in
      if (data == nil) {
          NSLog("Error Connection")
      }
      print("test2")
      let res = response as! NSHTTPURLResponse!
      if (my_code_HTTP(res.statusCode) == 0) {
          var jsonData:NSDictionary = NSDictionary()
          do {
              jsonData = try NSJSONSerialization.JSONObjectWithData(data!,options:NSJSONReadingOptions.MutableContainers) as! NSDictionary
              extract_data_projets(jsonData)
              extract_data_activity(jsonData)
              extract_data_history(jsonData)
              display_board()
          }
          catch {
              NSLog("Error")
          }
          my_connection_user()
          my_connection_notes()
      }
  })
  print("test3")
  task.resume()
  print("test4")
  }
  </code></pre>
  
  <p>This is what I get after compilation:</p>
  
  <pre><code> test1
   test3
   test4
   test2
  </code></pre>