[英]Error -swift-Tableview-custom cell
I got an error message that says" Could not find an overload for 'subscript' that accepts the supplied arguments" how can I fix it 我收到一条错误消息,内容为“找不到提供所提供参数的'下标'的重载”
//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
is probably not specified as an Array of Strings. children
可能未指定为字符串数组。 You need to explicitly cast children[indexPath.row]
to a String, or change the type of children
您需要显式转换children[indexPath.row]
为String,或者改变类型children
cell.textLabel?.text = children[indexPath.row] as! String
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.