title: UIKeyboardTaskQueue may only be called from the main thread
body: <p>I have a problem while trying to make a function that automatically create POST request, send them, get the response, and handle them then show UIAlertView to tell the user which problem it is.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>let task = session.dataTaskWithRequest(request, completionHandler:{ (data, response, error) -&gt; Void in
  
      dispatch_async(dispatch_get_main_queue(),{
          var alert = UIAlertController(title: "Chargement", message: "Envoi des informations...", preferredStyle: UIAlertControllerStyle.Alert)
          viewController.presentViewController(alert, animated: true, completion: nil)
  
  
          answer = NSString(data: data!, encoding: NSUTF8StringEncoding)!
          print(answer)
      var complete = false
      alert.dismissViewControllerAnimated(true, completion: { () -&gt; Void in
          complete = true
      })
  
      while(!complete)
      {
  
      }
      var textmsg: String
      if(answer == "#400")
      {
          textmsg = "Il manque une information !"
      }
      else if(answer == "#50")
      {
          textmsg = "Le compte fourni ne correspond pas."
      }
      else if(answer == "#100")
      {
          textmsg = "Impossible d'identifier l'application."
      }
      else if(answer == "#1")
      {
          textmsg = "Transfert terminé avec succès !"
      }
      else {
          textmsg = "Echec du transfert."
      }
      let alertComplete = UIAlertController(title: "Chargement", message: textmsg, preferredStyle: UIAlertControllerStyle.Alert)
      alertComplete.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
      viewController.presentViewController(alertComplete, animated: true, completion: nil)
      })
  })
  
  task.resume();
  </code></pre>
  
  <p>The error code is the following : </p>
  
  <pre><code>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] may only be called from the main thread.'
  </code></pre>
  
  <p>When my request return a bad response (the #400, #50, #100), the code works and show the UIAlertView but if the response is good, it gives me the error code as above.</p>