Как мне разобрать JSON со словарем в нем? - PullRequest
0 голосов
/ 15 июня 2019

Я пытаюсь проанализировать JSON и получить значение параметра «Имя». И я хочу отображать имена областей почтового индекса в метке в ячейке табличного представления.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "ourCell") as! ourTableViewCell
    let temp = pinCodeData!["Post Office"][indexPath.row][0].dictionaryObject as! Dictionary<String,String>

    let temp2 = temp["Name"]
    print(temp)
    cell.ourLabel.text = temp2
    return cell
    }
let apiURL = "http://www.postalpincode.in/api/pincode/122001"
func ret(){
    Alamofire.request(apiURL, method: .get).responseJSON { (response) in
        DispatchQueue.main.async {
            if response.result.isSuccess {
                self.pinCodeData = JSON(response.result.value!)
                self.outTableView.reloadData()
            }
        }
    }
}
...