var weibos: [
Int] =[];
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print("条数\(weibos?.count)");
return weibos?.count ?? 0
}
func loadData(){
//WeiboModel.loadData(0, max_id: 0) { (list, error) -> () in
self.weibos = [1];
print(self.weibos);
print(self.weibos?.count);
self.tableView.reloadData();
//}
}
以上 uitableview 的代理方法, app 启动的时候,能输出 “条数 1 ”
但是 如果将 WeiboModel.loadData 注释去掉,
函数里的代码还是能执行 print(self.weibos); 等于 1
但是 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) 这个代理方法就执行不了,导致页面表格出不来。。。
甚至我延迟 10 秒执行 print(self.weibos?.count);self.tableView.reloadData();,表格还是出不来。数组里 weibos 是有值的。。
为什么加了这个函数 WeiboModel.loadData 之后 self.tableView.reloadData()就不起作用了。里面只是封装了一个 AFNetworking 的请求而已。。。