"self" 使用未解析的标识符

Use of unresolved identifier for "self"

我的 viewController 有一个 PFQueryTableViewController 子类,我在代码中写 self 的任何地方都会遇到同样的错误。

我认为 PFQueryTableViewController 不会给我错误,但我会在这里提供我的代码。

我不确定为什么会遇到这个问题,因为我以前使用过这个确切的代码,但现在我收到了错误。是否缺少任何内容或我应该添加代码以消除此错误。

    import UIKit
    import Parse
    import CoreLocation


    @available(iOS 8.0, *)
    class ResponseViewController: PFQueryTableViewController, UITextFieldDelegate {

    var Reply:NSMutableArray! = NSMutableArray()
    var post:PFObject?


    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)

        let query = PFQuery(className: "Test")


            query.limit = 200;
            query.addAscendingOrder("createdAt")

            query.findObjectsInBackgroundWithBlock {(objects: [AnyObject]?, error: NSError?) -> Void in

                if error == nil{
                    for object in objects!{
                        let post : PFObject = object as! PFObject
                        self.Reply.addObject(post)
                    }

                    let array : NSArray = self.Reply.reverseObjectEnumerator().allObjects
                    self.Reply = NSMutableArray(array: array)

                    self.tableView.reloadData()

                }
            }

        }}

    func objectAtIndexPath(indexPath: NSIndexPath!) -> PFObject? {
    var obj : PFObject? = nil
    if(indexPath.row < self.objects!.count){
        obj = self.objects![indexPath.row] as? PFObject
    }

    return obj
}



       func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
            return post.count
        }



     func numberOfSectionsInTableView(tableView: UITableView) -> Int {
            return 1
        }

    func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?, object: PFObject!) -> PFTableViewCell? {
        let cell = tableView!.dequeueReusableCellWithIdentifier("responseCell", forIndexPath: indexPath!) as! ResponseCell
          if let respondersPost : PFObject = self.Reply.objectAtIndex(indexPath!.row) as! PFObject {
        cell.responder.text = object["userName"] as? String
        cell.respMessage.text = object["message"] as? String

        cell.respMessage.numberOfLines = 0
        let score = object[("count")] as! Int
        cell.likeCount.text = "\(score)"

        //    cell.userImage.image = object["photo"] as! PFFile
        cell.respMessage.text = respondersPost.objectForKey("message") as! String

        return cell
    }



    func sendReply(sender: AnyObject) {
                    let testObj = PFObject(className: "Responses")
                    print("***///let testObj = PFObject(className: \"Responses/***")


            //        testObj["location"] = PFGeoPoint(latitude: currLocation!.latitude , longitude: currLocation!.longitude)
                    testObj["count"] = 0
                    testObj["message"] = self.textfield.text
                    testObj.saveInBackgroundWithBlock { (success:Bool, error :NSError?) -> Void in
                        if error == nil
                        {
                            print("***///detail is saved///***")
                            self.dismissViewControllerAnimated(true, completion: nil)
                        }

        }

PFQueryTableViewController 是 ParseUI SDK 的一部分,因此如果您不在您的视图中导入它,您将 运行 遇到问题。

正确使用 PFQueryTableViewController

import UIKit
import ParseUI

class WaitListTVC: PFQueryTableViewController {

override init(style: UITableViewStyle, className: String?) {
    super.init(style: style, className: className)
}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)!

    self.parseClassName = CoursetyConstants.kWaitListClassName
    self.pullToRefreshEnabled = true
    self.paginationEnabled = true
}

override func queryForTable() -> PFQuery {
    let query = PFQuery(className: self.parseClassName!)
    //query.whereKey("user", equalTo: PFUser.currentUser()!)
    return query
}