Avatar
Kishikawa Katsumi 4/7/2018 1:33 AM
@swiftbot import Foundation let semaphore = DispatchSemaphore(value: 0) let url = URL(string: "http://httpbin.org/get")! let task = URLSession.shared.dataTask(with: url) { (data, response, error) in defer{ semaphore.signal() } if let error = error { print(error) return } print(response!.url!) print(String(data: data!, encoding: .utf8)!) }; task.resume() semaphore.wait()