简体   繁体   中英

Update User Column in Parse with New Data Swift

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

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

So try:

let query = PFQuery(className:"_User")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM