Xcode 在Parse类中更新列中的值
我正在尝试更新Parse中“currentUploads”类中的一列: 这就是我正在尝试的Xcode 在Parse类中更新列中的值,xcode,swift,parse-platform,Xcode,Swift,Parse Platform,我正在尝试更新Parse中“currentUploads”类中的一列: 这就是我正在尝试的 @IBAction func reportButtonAction(sender: AnyObject) { println("Report Button Pressed") let buttonPosition = sender.convertPoint(CGPointZero, toView: self.collectionView) let indexPath = self
@IBAction func reportButtonAction(sender: AnyObject) {
println("Report Button Pressed")
let buttonPosition = sender.convertPoint(CGPointZero, toView: self.collectionView)
let indexPath = self.collectionView.indexPathForItemAtPoint(buttonPosition)
var alertMessage = NSString(format: "*User: %@\r *Text: %@\r *Created at %@", imageUploader[indexPath!.row], imageText[indexPath!.row]/*, imageCreated[indexPath!.row]*/)
var reportAlert = UIAlertController(title: "Report Content", message:alertMessage as String, preferredStyle: UIAlertControllerStyle.Alert)
reportAlert.addAction(UIAlertAction(title: "Yes", style: .Default, handler: { (action: UIAlertAction!) in
println("Handle Report Logic here")
self.reportContent()
}))
reportAlert.addAction(UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in
println("Handle Cancel Logic here")
}))
presentViewController(reportAlert, animated: true, completion: nil)
}
func reportContent(){
let someQuery = PFQuery(className: "currentUploads")
someQuery.getObjectInBackgroundWithId("imageFile") {
(updatedObject: PFObject?, error: NSError?) -> Void in
if error != nil {
print(error)
} else if let updatedObject = updatedObject {
updatedObject["reportedCount"] = "1"
updatedObject.saveInBackground()
}
}
}
因此,我想将func reportContent
中所选图像的“reportedCount”更新/递增为1,但出现以下错误:
[错误]:没有与查询匹配的结果。(代码:101,版本:1.8.0)
可选(错误域=解析代码=101)“没有与查询匹配的结果。”
UserInfo=0x7fae8a484aa0{错误=没有与查询匹配的结果。,
NSLocalizedDescription=没有与查询匹配的结果,代码=101})
我相信这是因为您需要查询所有包含“imageFile”的实例,而不是实际的行。你想用像这样的东西吗
someQuery.whereKey(objectId, EqualTo: objectId)
和使用
someQuery.findObjectsInBackgroundWithBlock
其中objectId是要更改其reportedCount的对象的对象ID
那你就可以做了
object.setValue(object["reportedCount"] as! Int + 1, forKey: "reportedCount")
这都是psuedo代码,但这是我在用户添加新朋友时增加朋友数量的方法。我做错了什么吗-