其中是檢索評論的代碼?確保你在for循環之後調用「self.tableView.reloadData()」。
我一般檢索解析信息的方式是像這樣:
func query() {
var query = PFQuery(className: "comments")
query.orderByDescending("createdAt")
query.findObjectsInBackgroundWithBlock { (caption2: [AnyObject]?, erreur: NSError?) -> Void in
if erreur == nil {
// good
for caption in caption2! {
self.comments.append(caption["<YOUR COLUMN NAME WHERE COMMENT IS STORED IN PARSE HERE>"] as! String)
}
self.tableView.reloadData()
}
else {
// not good
}
}
}
添加此功能到您的類。然後改變這:
func reply() {
post?.addObject(commentView!.text, forKey: "comments")
post?.saveInBackground()
if let tmpText = commentView?.text {
comments?.append(tmpText)
}
commentView?.text = ""
println(comments?.count)
self.commentView?.resignFirstResponder()
self.commentTableView.reloadData()
}
這樣:
func reply() {
post?.addObject(commentView!.text, forKey: "comments")
post?.saveInBackground()
if let tmpText = commentView?.text {
comments?.append(tmpText)
}
commentView?.text = ""
println(comments?.count)
self.commentView?.resignFirstResponder()
self.query
}
我剛加了我全班 –
什麼循環之後? –
好吧,我添加了該函數,並修改了'reply()'函數,但是在self.comments.append(caption [「comments」] as String)中出現錯誤,說**不能使用參數列表類型的字符串**和錯誤在這裏:'self.tableView.reloadData()'與**不能調用reloadData沒有參數** –