title: Swift URL Session and URL Request not working
body: <p>I am getting very similar problems to <a href="https://stackoverflow.com/questions/39860879/swift-3-urlsession-urlrequest-not-working">this post</a>, but I don't fully understand the answer. I've created a completion handler, but it doesn't seem to be working as expected.</p>
  
  <pre><code>func updateTeam(teamID: Int) {
      startConnection {NSArray, Int in
          //Do things with NSArray
      }
  }
  
  func startConnection(completion: (NSArray, Int) -&gt; Void) {
      let url = URL(string: "http://www.example.com/path")
      var request : URLRequest = URLRequest(url: url!)
      request.httpMethod = "POST"
      let postString = "a=\(Int(teamInput.text!)!)"
      request.httpBody = postString.data(using: .utf8)
  
      let dataTask = URLSession.shared.dataTask(with: request) {
          data,response,error in
          print("anything")
          do {
              if let jsonResult = try JSONSerialization.jsonObject(with: data!, options: []) as? NSDictionary {
                  self.teamResult = jsonResult
                  print(jsonResult)
              }
          } catch let error as NSError {
              print(error.localizedDescription)
          }
  
      }
      dataTask.resume()
  
      completion(NSArray(object: teamResult), Int(teamInput.text!)!)
  }
  </code></pre>
  
  <p>Nothing within the dataTask statement seems to run, or at least it doesn't complete before I try to use the data resulted. What is wrong with this completion handler?</p>
  
  <p>Thank you in advance!</p>