title: reload table data in swift3
body: <p>My screen consist of add and delete buttons, if I clicked add button then it opens popup screen and I entered fields and clicked on save button on the popup screen then data is added, if I close the popup screen then the table is not reloaded. please check my code as shown below.</p>
  
  <pre><code>class EditTest: UIViewController , UITableViewDataSource, UITableViewDelegate {
      @IBOutlet weak var tableView: UITableView!
  
      var position = [AnyObject]()
      var company = [AnyObject]()
      var location = [AnyObject]()
  
   override func viewDidLoad() {
        super.viewDidLoad()
  loadJsonData()
  
  }
   func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int
      {
          return position.count
      }
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell
      {
          let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! customCell
  
      cell.position.text = position[indexPath.row] as? String
      cell.company.text = company[indexPath.row] as? String
      cell.location.text = location[indexPath.row] as? String
  
      return cell
      }
  
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
  
          PopupController
              .create(self)
              .customize(
                  [
                      .animation(.slideUp),
                      .scrollable(false),
                      .backgroundStyle(.blackFilter(alpha: 0.7))
                  ]
              )
              .didShowHandler { popup in
                  print("showed popup!")
              }
              .didCloseHandler { _ in
                  print("closed popup!")
              }
              .show(DeleteRow.instance())
  
      }
  
      @IBAction func newExp(_ sender: Any) {
  
          PopupController
              .create(self)
              .customize(
                  [
                      .animation(.slideUp),
                      .scrollable(false),
                      .backgroundStyle(.blackFilter(alpha: 0.7))
                  ]
              )
              .didShowHandler { popup in
                  print("showed popup!")
              }
              .didCloseHandler { _ in
                  print("closed popup!")
              }
             .show(AddRow.instance())
  
      }
  
    func loadJsonData() {
  
          let url = URL(string: "https://url..../id")
  
          var request = URLRequest(url: url!, cachePolicy: .reloadIgnoringCacheData,timeoutInterval: 10000)
  
          URLSession.shared.dataTask(with: request) { (data, response, error) in
              if error != nil {
                  print(error!)
                  return
              }
  
              do {
                  if let jsonData = try JSONSerialization.jsonObject(with:data!, options: []) as? [[String:AnyObject]] {
                      print(jsonData)
                      for item in jsonData {
  
                          if let pos = item["Position"] as? AnyObject{
                              self.position.append(pos)
                          }
                          if let comp = item["Company"] as? AnyObject{
                              self.company.append(comp)
                          }
                          if let location = item["Location"] as? AnyObject{
                              self.location.append(location)
                          }
                          DispatchQueue.main.async {
                              self.tableView.reloadData()
                          }
                      }
                  }
              } catch let error as NSError {
                  print(error)
              }
              }.resume()
  
      }
  
  }
  </code></pre>
  
  <p>In the above code, what changes I do to update table data when I close the popup.</p>
  
  <pre><code>func saveMethod(sender:UIButton){
          let paramaters = ["Id": id,
                            "Position": pos,
                            "Company": com,
                            "Location": loc] as [String : Any]
  
  let url = URL(string: “https://———/save”)!
          let session = URLSession.shared
          var request = URLRequest(url: url)
          request.httpMethod = "POST" //set http method as POST
  
          do {
              request.httpBody = try JSONSerialization.data(withJSONObject: paramaters, options: .prettyPrinted) // pass dictionary to nsdata object and set it as request body
  
          } catch let error {
              print(error.localizedDescription)
          }
  
          request.addValue("application/json", forHTTPHeaderField: "Content-Type")
          request.addValue("application/json", forHTTPHeaderField: "Accept")
  
          //create dataTask using the session object to send data to the server
          let task = session.dataTask(with: request as URLRequest, completionHandler: { data, response, error in
  
              guard error == nil else {
                  return
              }
  
              guard let data = data else {
                  return
              }
  
              do {
                  //create json object from data
                  if let json = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [String: Any] {
  
                      DispatchQueue.main.async {
                          // now update UI on main thread
  
                          let alert = UIAlertController(title: “Row”, message:   "Created Successfully", preferredStyle: .alert)
  
                          let OKAction = UIAlertAction(title: "OK", style: .default, handler: { _ -&gt; Void in
  
                              DispatchQueue.main.async {
                                  self.tableView.reloadData()
                              }
  
                          })
  
                          alert.addAction(OKAction)
                          self.present(alert, animated: true){}
                      }
                  }
  
              } catch let error {
                  print(error.localizedDescription)
              }
          })
          task.resume()
  
  }
  </code></pre>