Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用json在Swift中预测wunderground api_Json_Api_Swift_Wunderground - Fatal编程技术网

使用json在Swift中预测wunderground api

使用json在Swift中预测wunderground api,json,api,swift,wunderground,Json,Api,Swift,Wunderground,我试图从WundergroundAPI获取每小时的预测,但是我的代码返回了这个错误。 我对一个研究项目的WundergroundAPI中一天中特定小时的湿度预测感兴趣 let currenttt = jsonResult["current_observation"] as NSDictionary let currentttv = currenttt["display_location"] as NSDictionary let c: String!

我试图从WundergroundAPI获取每小时的预测,但是我的代码返回了这个错误。 我对一个研究项目的WundergroundAPI中一天中特定小时的湿度预测感兴趣

  let currenttt       = jsonResult["current_observation"] as NSDictionary
  let currentttv       = currenttt["display_location"] as NSDictionary
  let c: String!      = currentttv["city"] as NSString
这段代码在计算机上运行得非常好 但是为了获得不同时间的湿度,我需要添加什么


我正在尝试获取图标的信息,我知道这取决于我需要添加的小时或其他值,以便获得特定的“图标”

让URLAString“”

错误为“操作无法完成。(NSURErrorDomain错误-1001。)致命错误:在展开可选值(lldb)时意外发现为零”

和“线程10:EXC_断点(代码=EXC_ARM_断点,子代码=0xe7ffdefe)”


无需将“a”强制转换为NSString。字符串类型是推断出来的。

欢迎这样做!您遇到了什么错误?您能将其与您的问题一起发布吗?我正在尝试获取图标的信息,我知道这取决于我需要添加的小时或其他值,以便获得特定的“图标”。让URLAString让w=jsonResult[“hourly_forecast”]作为NSDictionary让f=w[“FCTTIME”]作为NSDictionary让a:String!=f[“icon”]作为NSString错误是“操作无法完成。(NSURErrorDomain错误-1001。)致命错误:在展开可选值(lldb)时意外发现为零”
let w       = jsonResult["hourly_forecast"] as NSDictionary
let f       = w["FCTTIME"] as NSDictionary
let a: String!      = f["icon"] as NSString
if let a = f["icon"] { print(a) }  

//prints 'mostly cloudy'