Xcode 6.3解析SDK 1.7.1 PFTableViewCell错误“;“具有不兼容类型”;
我的代码:Xcode 6.3解析SDK 1.7.1 PFTableViewCell错误“;“具有不兼容类型”;,xcode,uitableview,swift,parsing,pftableviewcell,Xcode,Uitableview,Swift,Parsing,Pftableviewcell,我的代码: override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject) -> PFTableViewCell{ var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as! CustomTableViewCell!
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'
我已经查找了所有的兼容性错误(删除!)。另一个帖子也有类似的问题:
但只有他们的第三个错误。这篇文章中的所有其他问题都得到了解决,但这个错误仍然存在。有什么解决方案或建议吗?我想出来了。使用以下
覆盖功能:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
//...
}
区别在于使PFObject
和PFTableViewCell
可选。我也有同样的问题。你知道了吗?Parse 1.7.2是可用的,但它不能解决这个问题。谢谢Clifton!我还发现的工作是:覆盖func tableView(tableView:UITableView,cellForRowAtIndexPath:nsindepath)->PFTableViewCell{if let objects=objects as?[PFObject]{for objects{。。。