zoukankan      html  css  js  c++  java
  • 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             })
    让明天,不后悔今天的所作所为
  • 相关阅读:
    Tornado输出和响应头
    sqlalchemy 学习(二)scoped session
    04:sqlalchemy操作数据库 不错
    sqlalchemy(二)高级用法
    红黑树
    Minimum Window Substring
    Max Points on a Line
    分治算法
    Maximum Subarray
    Word Break
  • 原文地址:https://www.cnblogs.com/-yun/p/5526119.html
Copyright © 2011-2022 走看看