tableView.reloadData() then fatal error: Index out of range

541 views Asked by At
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()
}

then

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
}

and when an update (tableView.reloadData()) -> fatal error:

Index out of range

tell me what my mistake?

0

There are 0 answers