我正在尝试从 Swift2 迁移到 Swift3,但我遇到了 URLSession.GET 问题
我浏览了 XCode 提供的迁移工具,并将我的“NSURLSession”调用更改为“URLSession”,但我一直收到以下错误消息:
"Use of Instance member 'GET' on type 'URLSession'; did you mean to use a value of type 'URLSession' instead?"
这是我的代码:
open static func getData() -> Promise<[Station]> {
return URLSession.GET("http://api.xxx.gov/api/").asDataAndResponse().then { (data: NSData, _) -> [Station] in
var stations = [Station]()
// rest of the code to retrieve the data
...
...
return stations
}
}
更新: 经过一番挖掘找到解决方案后,请参阅下面的答案以获取更多详细信息和有用的链接