Ios UITableView上的JSON数据

Ios UITableView上的JSON数据,ios,swift,api,uitableview,Ios,Swift,Api,Uitableview,为了下载飞行员的NOTAM,我设法从美国联邦航空局网站上下载了这个API。我设法发送参数“api密钥、位置、状态”的请求。我得到了我的JSON数据,它工作正常。现在我的问题是,我想在tableView上显示我以JSON格式返回的数组的一项,即名为“all”的项 我创建了IBOutlet。我给了手机识别码,但我被困在这里了 import UIKit import Alamofire import SwiftyJSON class ViewController: UIViewController,

为了下载飞行员的NOTAM,我设法从美国联邦航空局网站上下载了这个API。我设法发送参数“api密钥、位置、状态”的请求。我得到了我的JSON数据,它工作正常。现在我的问题是,我想在tableView上显示我以JSON格式返回的数组的一项,即名为“all”的项

我创建了IBOutlet。我给了手机识别码,但我被困在这里了

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 = "mykey"
    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("************************")
        }
    }
}

请根据JSON文件参考本教程和模型数据。网络请求退出主执行队列。

我用此代码解决

func tableView(tableView:UITableView,cellForRowAt indexath:indexPath)->UITableViewCell{ let cell=tableView.dequeueReusableCell(标识符为:“cellid”,表示:indexath)

//让text=array[indexPath.row] //cell.textLabel?.text=文本

    (cell.contentView.viewWithTag(1) as! UILabel).text = array[indexPath.row]
    (cell.contentView.viewWithTag(2) as! UILabel).text = array2[indexPath.row]
    return cell
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return array.count

}

感谢您的帮助。

您的问题是什么,是读取(理解)json数据还是不知道表视图是如何工作的。。。?