If you want to wait for the results of the block, just replace dispatch_asyncwith dispatch_sync:
dispatch_sync(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
let whois_url = NSURL(string: SEARCH_URL+self.combined+"/whois")
result = NSString(contentsOfURL: whois_url!, encoding: NSUTF8StringEncoding, error: nil)
print(result!)
})
This ensures that the method will not be returned until the URL content is obtained as a result.
source
share