Guest User

Untitled

a guest
Jun 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. import UIKit
  2. import Alamofire
  3. import SwiftyJSON
  4.  
  5. class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
  6.  
  7.  
  8. //Constants
  9. let notamUrl = "https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/states/notams/notams-realtime-list"
  10. let api_key = "5a743836e4b86182b233adf4b4201504"
  11. let notamModel = ModelloNotam()
  12.  
  13.  
  14. @IBOutlet weak var tableView: UITableView!
  15.  
  16. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  17. return //????????? i dont know
  18.  
  19. }
  20.  
  21. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  22. let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath)
  23.  
  24. // ????????? i dont know
  25.  
  26. return cell
  27. }
  28.  
  29.  
  30. override func viewDidLoad() {
  31. super.viewDidLoad()
  32.  
  33. tableView.delegate=self
  34. tableView.dataSource=self
  35.  
  36. func getNOTAM (url:String,parameters:[String:String]){
  37. Alamofire.request(url, method: .get, parameters: parameters).responseJSON {
  38. response in
  39. if response.result.isSuccess{
  40.  
  41. let notamJSON : JSON = JSON (response.result.value!)
  42.  
  43. self.displayNotam(json: notamJSON)
  44.  
  45.  
  46. }
  47.  
  48. else{
  49. print("errore connessione(response.result.error)")
  50. }}}
  51.  
  52. var locations = "VMMC"
  53. var state = "CHN"
  54. let params : [String : String] = ["locations" : locations, "state" : state, "api_key" : api_key]
  55. getNOTAM(url: notamUrl, parameters: params)
  56.  
  57.  
  58. }
  59.  
  60. func displayNotam (json:JSON) {
  61.  
  62. let conta = json.count
  63.  
  64. for var i in 0...conta {
  65. i = i + 1
  66. notamModel.all = json [i]["all"].stringValue
  67. notamModel.type = json [i]["type"].stringValue
  68. // print("The NOTAM type is (notamModel.type)")
  69. // print(notamModel.all)
  70. // print("************************")
  71. }
  72. }
  73. }
Add Comment
Please, Sign In to add comment