嘿伙计们我对Parse中的一个内容有很多意见。我想得到关于一条评论的输入数量。与计算喜欢类似。我怎么能这样做?
let guessstat:PFObject = PFObject(className: "Guesscontent")
var guessData:NSMutableArray = NSMutableArray()
func loadData(){
guessData.removeAllObjects()
let findTimeLineData:PFQuery = PFQuery(className: "Guesses")
findTimeLineData.whereKey("content", equalTo: self.guessTextView.text)
findTimeLineData.findObjectsInBackgroundWithBlock{
(objects: [PFObject]?, error: NSError?) -> Void in
if error == nil{
if let objects = objects {
for object in objects{
self.guessData.addObject(object)
}
}
let array:NSArray = self.guessData.reverseObjectEnumerator().allObjects
self.guessData = NSMutableArray(array: array)
}
}
guessstat["sell"] = guessData.count
}
答案 0 :(得分:0)
您应用中的每个输入都对应一个评论。您是否在实际猜测和猜测内容之间建立了关系?
首先,您可能需要在两个类之间建立关系......
var Guesscontent = PFObject(className:"GuessContent")
var Guesses = PFObject(className:"Guesses")
//Create the relationship
Guesses["parent"] = GuessContent
//Everytime a user has made a guess, save it
Guesses.saveInBackground()
然后尝试你正在做的事情......让我知道,我无法发表评论
答案 1 :(得分:0)
嘿伙计们我找到了解决方案
让query = PFQuery(className:“Guesses”)
query.whereKey("content", equalTo:self.guessTextView.text)
query.countObjectsInBackgroundWithBlock {
(count: Int32, error: NSError?) -> Void in
if error == nil
{
self.stattlabelsell.text = "\(count)"
}
}