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

标签 ios swift pfquery pftableviewcell

我的 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的正确方法

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
}

关于ios - 使用 "self"的未解析标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33428026/

相关文章:

ios - 允许的 iTunes Connect 用户的最大数量是多少?

ios - UIViewController如何跳转到祖 parent View ?

arrays - 基于多个属性在 Swift 中过滤数组

ios - Firebase 按值观察从缓存数据中获取旧值

ios - Swift3 Storekit - 将字符串数组转换为 Set<ProductIdentifier>

ios - 检查 Parse 数据库以查看输入的文本是否与字符串匹配时出错

ios - 根据子查询解析查询

ios - 监控和维护应用程序在磁盘上的大小的解决方案

iphone - PVR 纹理工具构建阶段

swift 和解析 : Query Results Where Column Class Is Equal To A Column In Users Class