Nicholas
Nicholas

Reputation: 149

Parse update PFUser Class String

I am trying to update a specific users "totalScore" column in my Users class in parse. The "totalScore" is a string value. I am running the code below in didSelectRowAtIndexPath:. I am getting self.friends from the queried list of users I want displayed in my tableview. When I run this code and log it, it seems to work fine but the object never updates in my data browser. Also: I am able to update this object online just not in app! Thanks!

 PFUser *user = [self.friends objectAtIndex:indexPath.row];

    PFQuery *query = [PFQuery queryWithClassName:@"_User"];
    [query whereKey:@"objectId" equalTo:user.objectId];
    [query getFirstObjectInBackgroundWithBlock:^(PFObject * userStats, NSError *error) {
        if (!error) {

            [userStats setObject:@"#5" forKey:@"totalScore"];

            [userStats saveInBackground];


        } else {
            // Did not find any UserStats for the current user
            NSLog(@"Error: %@", error);
        }
    }];

Upvotes: 0

Views: 264

Answers (1)

soulshined
soulshined

Reputation: 10602

You can't update any users information that's not you for security reasons. You have to be the currentUser to change your info.

Here is a workaround using cloud code : https://parse.com/questions/users-editing-other-users-in-javascript-sdk

Upvotes: 1

Related Questions