Xcode 6.3解析SDK 1.7.1 PFTableViewCell错误“具有不兼容的类型”

时间:2023-01-22 17:32:59

My code:

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

}

receives the following error

收到以下错误

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

I have looked up all the compatibility errors (removing !). Another post had a similar issue:

我查找了所有兼容性错误(删除!)。另一篇文章有​​类似的问题:

Parse SDK 1.7.1 not working in Xcode 6.3

解析SDK 1.7.1无法在Xcode 6.3中运行

But only their number 3 error. All other issues in that post were addressed, but this error remains. Any solutions or recommendations of where to look?

但只有他们的3号错误。该帖子中的所有其他问题都已得到解决,但此错误仍然存​​在。任何解决方案或建议在哪里看?

1 个解决方案

#1


4  

I figured it out. Use the following override function:

我想到了。使用以下覆盖功能:

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

The difference is making the PFObject and the PFTableViewCell optionals.

不同之处在于制作PFObject和PFTableViewCell选项。

#1


4  

I figured it out. Use the following override function:

我想到了。使用以下覆盖功能:

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

The difference is making the PFObject and the PFTableViewCell optionals.

不同之处在于制作PFObject和PFTableViewCell选项。