Search code examples
iosswiftxcode6.1

Use of undeclared type tableViewCell Swift


Can someone tell me what am I missing or doing wrong?

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
}

The error occurs on the tableViewCell and i been on this for hours but cant figure out whats wrong.


Solution

  • The error is caused by the fact that tableViewCell is neither an inherent type, nor a type that you've created. Instead of tableViewCell, you probably meant to use UITableViewCell, PFTableViewCell, or a custom class's cell. But from the error it seems as if tableViewCell has never been declared as a type.

    From your comments underneath the question, it's clear that you are in fact using a custom cell named VoteTableViewCell. Therefore you should initialize cell as a VoteTableViewCell; but make sure it's a custom PFTableViewCell and not a custom UITableViewCell since your cellForRowAtIndexPath method returns a PFTableViewCell.