The UITableView cell cannot be refreshed after swift adds the closure.

  ios, question
var weibos :[Int]?  ;
 ...
 self.loadData();
 ...
 
 func loadData(){
 //WeiboModel.loadData(0, max_id: 0) { (list, error) -> () in
 
 self.weibos = [];
 for(var i=0;  i<10;  I plus)
 self.weibos?  .append(i);
 bracket
 Print ("WeiboModel.loadData can be executed here with or without comments");
 //}
 bracket
 
 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
 (weibos?  .count)");
 return weibos?  .count ?  ?  zero
 bracket
 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
 let cell = UITableViewCell();
 cell.textLabel?  .text = String(weibos?  [indexPath.row]);
 return cell;
 bracket

This is the code for ios uitableview.
After running app, 10 rows of cells can be displayed in the interface.
However, if i don’t comment on the WeiboModel.loadData method.
The following elements added to the array can still be executed, and the array inside also has values, but several proxy methods of tableVIew have all failed.
Whether tableView.reloadData (), or changing the value of the array, the cells are not displayed.

Please help, debug all day. . . . . . . . . .

Code:https://github.com/iScript/swift-project/blob/master/ySeed/HomeViewController.swift

Is WeiboModel.loadData asynchronous? If it is asynchronous, you can explain it by adding after the for loop append element is completed

self.tableView.reloadData()

The reason may be that the reload of table was executed before the element was added. when the element was added, table will not reload again automatically, and the reloadData method needs to be called manually.

clipboard.png

The tableView in the red box inside at the bottom is a local variable, which overrides the private instance variable at the top, so the tableView when reloading is not the tableView you added to self.view