//
// ViewController.swift
// almo4
//
// Created by Yogesh Tomar on 1/18/19.
// Copyright © 2019 Yogesh Tomar. All rights reserved.
//
import UIKit
import Alamofire
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate{
@IBOutlet weak var tableView: UITableView!
var weatherArray = [AnyObject]() //= [[String: Any]]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
hh()
print("load web services")
print(weatherArray)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func hh(){
Alamofire.request("https://myinboxhub.co.in/APIS/services/IOSApiSimpleData").responseJSON{ response in
let result = response.result
if let dic = result.value as? Dictionary{
if let innerDict = dic["Result"]{
self.weatherArray = innerDict as! [AnyObject]
self.tableView.reloadData()
}
}
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return weatherArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell{
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for:indexPath) as? CustomTableViewCell
let name = weatherArray[indexPath.row]["name"]
cell?.idLabel.text = name! as! String
let subtitle = weatherArray[indexPath.row]["subtitle"]
cell?.nameLabel.text = subtitle! as? String
return cell!
}
}