Working on Swift 3 Xcode 9.1
I have two view controllers (one MainView and one Table View)
Problem: The Table View loads data from an API and displays it, however it take too long. I'm trying to have the load occur on the Main Controller.
I tried creating a custom method How to instantiate and load a view controller before segueing to it using swift
However the Table View has too many functions and I'm not sure how to call it.
Table View Code:
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
return cell
}
func loadData(){
//loads data
DispatchQueue.main.sync(execute:{
self.tableView.reloadData()
}
Question: Is creating a custom method the best way or is there another way? Please note I'm trying to do all this is the Main View Controller so the data can load once I segue to the Table View.