I'm using parse on Xcode 7.2 and I'm having trouble updating the object with swift. I want to update my boolean value in parse class column "Approve" and my class name is "Request" and I have "FromUserName" column which is type String and "ToUsername" column which is String as well
This is my code in swift
func block(){
let name = self.userDelName
let query = PFQuery(className: "Request")
//let username = PFUser.currentUser()?.username!
if let username = PFUser.currentUser()?.username! {
query.whereKey("ToUsername", equalTo: username)
}
query.whereKey("FromUsername", equalTo: name)
print(name+" IMHEHEHEHEHERRRR")
query.getFirstObjectInBackgroundWithBlock{(object,error) -> Void in
if error == nil {
print(object)
object!["Approve"] = false
object!.saveInBackgroundWithBlock {(success: Bool, error: NSError?) -> Void in
if (success) {
print("success")
} else {
print("down")
print(error)
}
}
}
}
}
and the error is
[Error]: object not found for update (Code: 101, Version: 1.11.0)
I don't know what to do now.
Any help is appreciated. Thank you
EDIT: this is my saved method
requested = PFObject(className: "Request")
requested!["From"] = PFUser.currentUser()
requested!["FromUsername"] = PFUser.currentUser()?.username
requested!["ToUsername"] = user
requested!["To"] = newFriend
requested!["Approve"] = true
requested!.saveInBackgroundWithBlock {(success: Bool, error: NSError?) -> Void in
if error == nil {
print("success")
}
else{
print(error)
}
}