有人能告诉我我错过了什么或做错了吗?
override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!, object: PFObject!) -> PFTableViewCell! {
let cell = tableView.dequeueReusableCellWithIdentifier("chatCell", forIndexPath: indexPath) as
tableViewCell
cell.chatText.text = object.valueForKey("chatText") as String
cell.chatText.numberOfLines = 0
let score = object.valueForKey("count") as Int
cell.count.text = "\(score)"
cell.time.text = "\((indexPath.row + 1) * 3)m ago"
cell.replies.text = "\((indexPath.row + 1) * 1) replies"
return cell
}
tableViewCell上发生了错误,我已经在这几个小时了,但是不知道什么是错的。
答案 0 :(得分:3)
错误是由tableViewCell
既不是固有类型也不是您创建的类型引起的。您可能打算使用tableViewCell
,UITableViewCell
或自定义类的单元格而不是PFTableViewCell
。但是从错误来看,似乎tableViewCell
从未被声明为类型。
根据您在问题下方的评论,很明显您实际上正在使用名为VoteTableViewCell
的自定义单元格。因此,您应该将cell
初始化为VoteTableViewCell
;但要确保它是自定义PFTableViewCell
而不是自定义UITableViewCell
,因为您的cellForRowAtIndexPath
方法会返回PFTableViewCell
。