Uitableview Xcode 9赢得´;无法识别TableViewCell的标识符
我得到了这个错误:“从未使用过不可变值‘cell’的初始化;请考虑用赋值替换或删除它。”Uitableview Xcode 9赢得´;无法识别TableViewCell的标识符,uitableview,swift4,xcode9,Uitableview,Swift4,Xcode9,我得到了这个错误:“从未使用过不可变值‘cell’的初始化;请考虑用赋值替换或删除它。” 我使用“单元格”作为TableViewCell的标识符。我怎样才能修好它 错误消息确实说明了一切:您正在为常量单元格指定一个值,但从不使用该值 另外,函数tableView(:cellForRowAt:)被声明为返回UITableViewCell实例,而您永远不会这样做 修复这两个问题会导致以下代码: func tableView(_ tableView: UITableView, cellForRowAt
我使用“单元格”作为TableViewCell的标识符。我怎样才能修好它 错误消息确实说明了一切:您正在为常量
单元格指定一个值,但从不使用该值
另外,函数tableView(:cellForRowAt:)
被声明为返回UITableViewCell实例,而您永远不会这样做
修复这两个问题会导致以下代码:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = companyTableView.dequeueReusableCell(withIdentifier: "cell")
}
提到的错误是一个警告(黄色)。关于缺少返回值,必须存在另一个实际错误(红色)。添加缺少的返回单元格可能会有所帮助。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell")
// do stuff with the cell
return cell
}