我得到了一個錯誤,指出消息「無法找到該接受提供的參數‘下標’超載」我怎麼能解決這個問題錯誤-swift-泰伯維-custome細胞
//declaration of children
var children = [Child]()
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell:UITableViewCell = UITableViewCell(style:UITableViewCellStyle.Default, reuseIdentifier:"Cell")
cell.textLabel?.text = children[indexPath.row] //error appears here
return cell
}
是什麼'children'類型的類型? – vadian
它是一個子類型的數組 – batool
可能是可選的,不是嗎?不要這樣做。對於表視圖數據源,聲明數組始終是非可選的空數組,如'var children = [Child]()' – vadian