无法为tableview单元控制器变量赋值

时间:2017-03-20 10:19:27

标签: ios swift swift3

我正在处理一个项目,我需要为每个tableview单元分配一个id,这样我就可以在正确的用户上运行该操作 这是我的代码:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = self.results.dequeueReusableCell(withIdentifier: "searchcell") as! SearchTVC
    cell.username.text = self.filtered[indexPath.row].username as! String
    cell.id = self.filtered[indexPath.row].id as! String

    return cell
}

当我尝试打印id时,我得到一个异常,告诉我id是nil

0 个答案:

没有答案
相关问题