无法拨打网络电话
Unable to make network call
我正在尝试向 forecast.io 拨打网络电话以获取天气预报。我的代码如下所示:
class ViewController: UIViewController {
private let apiKey = "" // 32 letters and numbers
override func viewDidLoad() {
super.viewDidLoad()
let baseURL = NSURL(string: "https://developer.forecast.io/forecast/\(apiKey)/")
let forecastURL = NSURL(string: "37.8267,-122.423", relativeToURL: baseURL)
let weatherData = NSData(contentsOfURL: forecastURL!, options: nil, error: nil)
println(weatherData)
}
}
println() 只是 returns 零。当我登录 forecast.io 时,我发现我还没有打电话。我的代码有什么问题?
问题出在url:
"https://developer.forecast.io/forecast/
应该是
"https://api.forecast.io/forecast/
我正在尝试向 forecast.io 拨打网络电话以获取天气预报。我的代码如下所示:
class ViewController: UIViewController {
private let apiKey = "" // 32 letters and numbers
override func viewDidLoad() {
super.viewDidLoad()
let baseURL = NSURL(string: "https://developer.forecast.io/forecast/\(apiKey)/")
let forecastURL = NSURL(string: "37.8267,-122.423", relativeToURL: baseURL)
let weatherData = NSData(contentsOfURL: forecastURL!, options: nil, error: nil)
println(weatherData)
}
}
println() 只是 returns 零。当我登录 forecast.io 时,我发现我还没有打电话。我的代码有什么问题?
问题出在url:
"https://developer.forecast.io/forecast/
应该是
"https://api.forecast.io/forecast/