码迷,mamicode.com
首页 > 编程语言 > 详细

Swift +AFNetworking3.0 Get

时间:2016-05-25 11:14:48      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

 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             })

 

Swift +AFNetworking3.0 Get

标签:

原文地址:http://www.cnblogs.com/-yun/p/5526119.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!