Xcode 6.3 Parse SDK 1.7.1 PFTableViewCell错误“具有不兼容的类型"; [英] Xcode 6.3 Parse SDK 1.7.1 PFTableViewCell Error "has incompatible type"
本文介绍了Xcode 6.3 Parse SDK 1.7.1 PFTableViewCell错误“具有不兼容的类型";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码:
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'
我查找了所有兼容性错误(删除!).另一则帖子也有类似的问题:
I have looked up all the compatibility errors (removing !). Another post had a similar issue:
但是只有他们的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?
推荐答案
我知道了.使用以下override
函数:
I figured it out. Use the following override
function:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
//...
}
区别在于PFObject
和PFTableViewCell
是可选的.
这篇关于Xcode 6.3 Parse SDK 1.7.1 PFTableViewCell错误“具有不兼容的类型";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文