swift NSURLSession_Example.swift

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了swift NSURLSession_Example.swift相关的知识,希望对你有一定的参考价值。

import UIKit
import Foundation
import PlaygroundSupport

PlaygroundPage.current.needsIndefiniteExecution = true

let url = URL(string: "http://www.google.com/")!
let task = URLSession.shared.dataTask(with: url) { data, response, error in
    
    if let error = error {
        print(error)
        return
    }
    
    print(response)
    
}

task.resume()

以上是关于swift NSURLSession_Example.swift的主要内容,如果未能解决你的问题,请参考以下文章