我试图通过网络电话预测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()只返回nil。当我登录到forecast.io时,我发现我还没有打过电话。我的代码出了什么问题?
答案 0 :(得分:0)
问题在于网址:
"https://developer.forecast.io/forecast/
应该是
"https://api.forecast.io/forecast/