答案 0 :(得分:1)
NSURLConnection
而只使用NSURLSession
。
在您的情况下,它看起来大致如下:
let url = NSURL(string: urlString as String))
var task: NSURLSessionDataTask!
let configuration = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: configuration)
let request = NSMutableURLRequest(URL: url)
task = session.dataTaskWithRequest(request, completionHandler: { (data, response, error) -> Void in
// Your code
})
task.resume()