'is it possible to update and save a pfobject from a query using parse?

Is it possible to do this:

PFQuery *query = [PFQuery queryWithClassName:@"GameScore"];
[query whereKey:@"playerName" equalTo:@"Dan Stemkoski"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  if (!error) {

           // THis is the part that isn't working
            PFObject *pTeam = objects[0];
            [pTeam setObject:@"new team name" forKey:@"team"];
            [pTeam saveInBackground];
  } else {
    // Log details of the failure
    NSLog(@"Error: %@ %@", error, [error userInfo]);
  }
}];

When I update the found query object and save, it is not saved to the server.

Is what I am doing possible and if so what am I doing wrong?



Solution 1:[1]

Try the below one, it works for me.

        PFObject *pTeam = [PFObject objectWithoutDataWithClassName:"GameScore" objectId: [object[0] objectId]];

        [pTeam setObject:@"new team name" forKey:@"team"];
        [pTeam saveInBackground];

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 General Grievance