小编Júl*_*ðni的帖子

Xcode Swift 3 NSURLSession.sharedSession

我试图更新我用swift 2制作的基本天气应用程序到swift 3这是我的代码:

func getWeather(city: String) {

    let path = "http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=095711373620570aa92ee530246dc8af"
    let url = NSURL(string: path)
    let session = NSURLSession.sharedSession()
    let task = session.dataTaskWithURL(url!) { (data: NSData?, response: NSURLResponse?, error: NSError?) -> Void in
        print(">>>> \(data)")
    }
Run Code Online (Sandbox Code Playgroud)

和NSURLSession.sharedSession(第5行)和NSURLResponse(第6行)打印出错误

xcode nsurl nsurlsession swift3 xcode8

0
推荐指数
1
解决办法
5586
查看次数

标签 统计

nsurl ×1

nsurlsession ×1

swift3 ×1

xcode ×1

xcode8 ×1