Swift +AFNetworking3.0 Get
1 let manager = AFHTTPSessionManager()
2 let url = "http://v.juhe.cn/weather/index"
3 let params = ["format":2,"cityname":city,"key":"ead46e88f98d0cd48730bdcde2"]
4
5 //progress做任务进度获取
6 manager.GET(url, parameters: params, progress: nil, success: { (_, JSON) in
7 print(JSON)
8 var temperature: String
9 var weatherIcon: String
10 var weatherText: String
11
12 let dis = JSON as! NSDictionary
13
14
15 temperature = (dis["result"]?["today"]?!["temperature"]?! as? String)!
16 weatherText = (dis["result"]?["today"]?!["weather"]?! as? String)!
17 weatherIcon = (dis["result"]?["today"]?!["weather_id"]?!["fa"]?! as? String)!
18
19 self.temperature.text = temperature
20 self.Weather.text = weatherText
21 self.location.text = city
22
23
24 default:
25 print("Error==")
26 }
27
28
29
30 }, failure: { (_, error) in
31 print(error)
32
33 })
让明天,不后悔今天的所作所为
posted on 2016-05-25 10:29 Sinner_Yun 阅读(443) 评论(0) 编辑 收藏 举报