2015-05-01 19 views
5

Mã của tôi:Xcode 6.3 Parse SDK 1.7.1 PFTableViewCell Lỗi "có kiểu không tương thích"

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 

}

nhận được lỗi sau

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

tôi đã xem xét tất cả các khả năng tương thích lỗi (loại bỏ!). bài khác đã có một vấn đề tương tự:

Parse SDK 1.7.1 not working in Xcode 6.3

Nhưng chỉ lỗi số 3 của họ. Tất cả các vấn đề khác trong bài viết đó đã được giải quyết, nhưng lỗi này vẫn còn. Bất kỳ giải pháp hoặc đề xuất về nơi để tìm?

+0

Tôi gặp vấn đề tương tự. Bạn đã bao giờ tìm ra nó chưa? –

+0

Phân tích cú pháp 1.7.2 có sẵn nhưng không khắc phục được sự cố này. –

Trả lời

4

Tôi đã tìm ra. Sử dụng các override chức năng sau:

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

Sự khác biệt là làm cho PFObjectPFTableViewCell optionals.

+0

Cảm ơn Clifton! Những gì tôi cũng đã tìm thấy các công trình là: ghi đè lên func tableView (tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> PFTableViewCell { nếu để đối tượng = đối tượng? [PFObject] { cho đối tượng trong đối tượng {... – Rob

Các vấn đề liên quan