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

  ios, question
var weibos :[Int]?  ;
 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);
 Print ("WeiboModel.loadData can be executed here with or without comments");
 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
 (weibos?  .count)");
 return weibos?  .count ?  ?  zero
 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
 let cell = UITableViewCell();
 cell.textLabel?  .text = String(weibos?  [indexPath.row]);
 return cell;

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. . . . . . . . . .


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


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.


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