我有一個ViewController
,其中TableView
在裏面,現在TableView
的數據在另一個類中異步地通過http調用拉取。iOS Swift:在TableView上顯示異步數據
class ViewController1: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
MyHttpClass().getData()//INITIATING getting data asynchronously
...
}
MyHttpClass
異步幾秒鐘後得到的數據,但它不具備ViewController
的參考交出的數據(理想情況下ViewController.tableView.reloadData - 是我需要調用)
有沒有更好的方法來處理這個問題?我如何獲得參考。到ViewController
實例何時MyHttp
獲取數據?任何更好的方法來處理這個?