Pardon me for beginner's question. I'm following a tutorial, it has the following snippet.
I don't understand the point of dispatch_async, if you execute the block self.webView... on the main queue on the main thread by calling dispatch_get_main_queue() anyway, why bother putting it inside dispatch_async?
Thanks
let url = NSURL(string: "http://www.stackoverflow.com")
let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {
(data, response, error) in
if error == nil {
var urlContent = NSString(data: data, encoding: NSUTF8StringEncoding)
println(urlContent)
dispatch_async(dispatch_get_main_queue()) {
self.webView.loadHTMLString(urlContent!, baseURL: nil)
}
}
}
task.resume()