I am new to Swift, and am trying to create a table that reads JSON data from my website. I followed some tutorials, and was able to get my code to work with a table controller. Now I'm trying to use a view controller with a table view inside, so I can have more customization. My problem is, I can't get the data to actually show up when I try to use my new code.
This is what I have in my viewController.swift:
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var tableView: UITableView!
var TableData:Array< String > = Array < String >()
override func viewDidLoad() {
    super.viewDidLoad()
    get_data_from_url("http://www.stevenbunting.org/Alliris/service.php")
}
func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return TableData.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    cell.textLabel?.text = TableData[indexPath.row]
    return cell
}
func get_data_from_url(_ link:String)
{
    let url:URL = URL(string: link)!
    let session = URLSession.shared
    let request = NSMutableURLRequest(url: url)
    request.httpMethod = "GET"
    request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringCacheData
    let task = session.dataTask(with: request as URLRequest, completionHandler: {
        (
        data, response, error) in
        guard let _:Data = data, let _:URLResponse = response  , error == nil else {
            return
        }
        self.extract_json(data!)
    })
    task.resume()
}
func extract_json(_ data: Data)
{
    let json: Any?
    do
    {
        json = try JSONSerialization.jsonObject(with: data, options: [])
    }
    catch
    {
        return
    }
    guard let data_list = json as? NSArray else
    {
        return
    }
    if let countries_list = json as? NSArray
    {
        for i in 0 ..< data_list.count
        {
            if let country_obj = countries_list[i] as? NSDictionary
            {
                if let country_name = country_obj["user"] as? String
                {
                    if let country_code = country_obj["friendlist"] as? String
                    {
                        TableData.append(country_name + " [" + country_code + "]")
                    }
                }
            }
        }
    }
    DispatchQueue.main.async(execute: {self.do_table_refresh()
    })
}
func do_table_refresh()
{
    self.tableView.reloadData()
}
}
 
     
    