title: Swift - Grand Central Dispatch vs Blocks/Closures
body: <p>I'm trying to write an HTTP request using Swift and I really only see people going one way or another (actually not so much GCD) to do HTTP requests on iOS. </p>
  
  <p><strong>If I want to make an HTTP request in iOS, what would be the best way to go about it: Use Grand Central Dispatch or write some closure block?</strong> Also, where can I find some great examples. From what I read online, I'm having a hard time seeing the benefits of one over the other.</p>
  
  <p>At the moment, I have this code:</p>
  
  <pre><code>    let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
  
      dispatch_async(dispatch_get_global_queue(priority, 0), { ()-&gt;() in
  
          self.activityIndicator.startAnimating()
          self.authenticateUser()
  
          dispatch_async(dispatch_get_main_queue(), {
              self.activityIndicator.stopAnimating()
          })
      })
  </code></pre>
  
  <p>From what I see in the Debug Session tab for the Processor, I can see it jump from Thread X to Thread Y (for authenticateUser) and back to Thread X. Which is good - this is what I want (I'm sure). </p>
  
  <p>Any good examples of GCD or Blocks/Closures written in Swift that you might be aware of would be very handy too. Thanks!</p>