【发布时间】:2017-06-14 23:41:58
【问题描述】:
这是来自调试。
url String "https://openweathermap.org/img/w/Optional(\50n\).png"
问题出在这一行:
self.imgURL = "https://openweathermap.org/img/w/\(self.dodatek).png"
当我将 (self.dodatek) 例如更改为图标 50n 时,它可以工作并显示图标。 当我启动我的天气应用程序并写下城市名称时,我想要这样的 url,但对于 50n,它必须是我从 json 中获取的变量。
https://openweathermap.org/img/w/50n.png
【问题讨论】:
-
除
let urlRequest = URLRequest(url: URL(string: url)!)之外的所有代码都与确定问题无关。字符串url的值是多少?使用调试器! -
最常见的问题是字符串为空或 URL 格式无效
-
我更新了问题。
标签: ios json swift weather-api