我有一个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)
}
}