title: how to Reload data on table view without crashing in swift 3?
body: <p>I have a TableView in my app that when user tap the button in one of the cells the safari will open in the app and when the safari dismiss the app will crash because I want to update one of the parameters in the tableview so I need to remove all and append them again from Json But this will take some seconds so the app will crash because there is no data to show I used Timer But timer is not good solution because some times it will take more time than timer so it will crash again I need a method that wait to finish and then do some thing else of if you think this is not a good solution too please guide me which solution is good for this problem  </p>
  
  <p>here is what I used in my app after dismiss safari in application(its not all of the codes but these codes has problems )</p>
  
  <pre><code> if let payed = dict.value(forKey: "payed"){
  
                              factorViewController.payed.removeAll()
                              self.factorTableView.reloadData()
                              factorViewController.payed.append(payed as! Int)
                              self.factorTableView.reloadData()
  
                              print("payed = \([payed])")
  
                          }
  </code></pre>