Xcode 6.3 Parse SDK 1.7.1 PFTableViewCell Error "has incompatible type"



我的代码:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject) -> PFTableViewCell{
    var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as!
        CustomTableViewCell!
    if cell == nil {
        cell = CustomTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CustomCell")
    }
    // Extract values from the PFObject to display in the table cell
    if let username = object["username"] as? String {
        cell.customUser.text = username
    }
    if let title = object["Title"] as? String {
        cell.customTitle.text = title
    }
    // Display image
    var initialThumbnail = UIImage(named: "Swarm_Bee.png")
    if let thumbnail = object["imageFile"] as? PFFile {
        thumbnail.getDataInBackgroundWithBlock{
            (imageData, error) -> Void in
            if error == nil {
                let image = UIImage(data: imageData!)
                cell.customImage.image = image
            }}
    }
    return cell

}

收到以下错误

 overriding method with selector 'tableView:cellForRowAtIndexPath:object:' has incompatible type '(UITableView,NSIndexPath,PFObject) -> PFTableViewCell'

我查找了所有兼容性错误(删除!)。另一个帖子也有类似的问题:

解析SDK 1.7.1在Xcode 6.3

中不起作用

,但只有3号错误。该职位中的所有其他问题都解决了,但此错误仍然存在。有任何解决方案或建议?

我弄清楚了。使用以下override函数:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? { 
  //... 
}

区别是使PFObjectPFTableViewCell选项。

相关内容