0

我有一个PFQueryTableViewController子类,viewController无论我self在我的代码中写什么,我都会遇到同样的错误。

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

我不确定为什么会出现这个问题,因为我之前使用过这个确切的代码,现在我收到了错误。是否有任何遗漏或我应该添加的代码以消除此错误。

    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)
                        }

        }
4

2 回答 2

0

正确的使用方法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
}
于 2015-10-30T04:26:16.173 回答
0

PFQueryTableViewController是 ParseUI SDK 的一部分,所以如果你没有在你的视图中导入它,你将会遇到问题。

于 2015-10-30T04:25:04.343 回答