Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- import Alamofire
- import SwiftyJSON
- class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
- //Constants
- let notamUrl = "https://v4p4sz5ijk.execute-api.us-east-1.amazonaws.com/anbdata/states/notams/notams-realtime-list"
- let api_key = "5a743836e4b86182b233adf4b4201504"
- let notamModel = ModelloNotam()
- @IBOutlet weak var tableView: UITableView!
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return //????????? i dont know
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "customCell", for: indexPath)
- // ????????? i dont know
- return cell
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- tableView.delegate=self
- tableView.dataSource=self
- func getNOTAM (url:String,parameters:[String:String]){
- Alamofire.request(url, method: .get, parameters: parameters).responseJSON {
- response in
- if response.result.isSuccess{
- let notamJSON : JSON = JSON (response.result.value!)
- self.displayNotam(json: notamJSON)
- }
- else{
- print("errore connessione(response.result.error)")
- }}}
- var locations = "VMMC"
- var state = "CHN"
- let params : [String : String] = ["locations" : locations, "state" : state, "api_key" : api_key]
- getNOTAM(url: notamUrl, parameters: params)
- }
- func displayNotam (json:JSON) {
- let conta = json.count
- for var i in 0...conta {
- i = i + 1
- notamModel.all = json [i]["all"].stringValue
- notamModel.type = json [i]["type"].stringValue
- // print("The NOTAM type is (notamModel.type)")
- // print(notamModel.all)
- // print("************************")
- }
- }
- }
Add Comment
Please, Sign In to add comment