Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift tableView.reloadData()然后出现致命错误:索引超出范围_Swift_Reloaddata_Removeall - Fatal编程技术网

Swift tableView.reloadData()然后出现致命错误:索引超出范围

Swift tableView.reloadData()然后出现致命错误:索引超出范围,swift,reloaddata,removeall,Swift,Reloaddata,Removeall,然后 当更新(tableView.reloadData())->致命错误时: 索引超出范围 告诉我我的错误是什么?你能告诉我们你的“NumberOfRowInstition”方法吗?强烈建议不要使用Swift类型(Array)作为变量名确保“NumberOfRowSection”返回“Array.count”数组名例如滚动更新表视图并确定!在tableView.reloadData()中出现错误 var Array = [String]() NSTimer.scheduledTimerWi

然后

当更新(tableView.reloadData())->致命错误时:

索引超出范围


告诉我我的错误是什么?

你能告诉我们你的“NumberOfRowInstition”方法吗?强烈建议不要使用Swift类型(
Array
)作为变量名确保“NumberOfRowSection”返回“Array.count”数组名例如滚动更新表视图并确定!在tableView.reloadData()中出现错误
var Array = [String]()  

NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: #selector(ViewController.func), userInfo: nil, repeats: true)

func(){
    Array.removeAll()
    ...
    for value in data{
        ...
        Array.append(string_value)
        ...
    }
    ...
    tableView.reloadData()
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCel{

      cell.label.text = Array[indexPath.row]
      return cell

}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return self.Array.count
}