2
votes

I want to update the telephone column and name column in the User Class with new values entered by user. I am using the same code recommended by Parse. Avoided changing anything except what is needed to try it out, but it is triggering an error. This is the error I get when I click to update the telephone and name of the user.

2015-12-08 20:55:26.044 Mawq[39532:1084556] [Error]: No results matched the query. (Code: 101, Version: 1.10.0) Optional(Error Domain=Parse Code=101 "No results matched the query." UserInfo={error=No results matched the query., NSLocalizedDescription=No results matched the query., code=101})

and this is the code in the function:

if(nameTextField.text != "" && telephoneTextField.text != "")
        {
            /*Update*/
            let query = PFQuery(className:"User")
            query.getObjectInBackgroundWithId(PFUser.currentUser()!.objectId!) {
                (gameScore: PFObject?, error: NSError?) -> Void in
                if error != nil {
                    print(error)
                } else if let gameScore = gameScore {
                    print("Telephone New: " + self.telephoneTextField.text!);
                    gameScore["telephone"] = self.telephoneTextField.text!
                    gameScore["name"] = self.nameTextField.text!
                    gameScore.saveInBackground()
                }
            }
        }

And the parse documentation is here: https://parse.com/docs/ios/guide#objects-updating-objects

1
What are you trying to do with the User column in Parse? - Lukesivi
I want to update the telephone column and name column in the User Class with new values entered by user. - ksa_coder
Have you tried this method: parse.com/docs/ios/guide#users-signing-up ? - Lukesivi
@lukesIvi I used that for a signup function but it's not relevant here since am updating 2 columns not creating a new record - ksa_coder
Why are you querying when you already have the user - just retrieve PFUser.currentUser(), update that object and then save it - Paulw11

1 Answers

2
votes

The problem might be the fact that Parse uses the User className as "_User".

So try:

let query = PFQuery(className:"_User")