@IBOutlet weak var mainTableView: UITableView!
var taskArray: [Task]? = nil
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "mainCell") as! mainCell
taskArray = CoreDataHandler.fetchObject()
let task = taskArray![indexPath.row]
cell.titleLabel.text = task.title
//cell.dateLabel.text = String(task.date)
return cell
}
我总是得到这样的错误:“Thread1: Fatal error: Index out out range”:let task = taskArray。有人能帮我吗?
https://stackoverflow.com/questions/50774506
复制相似问题