Updating Saved Data in Parse iOS

陌路散爱 提交于 2019-12-13 02:52:06

问题


I use this code to update my data on data browser on parse.

PFQuery *query = [PFQuery queryWithClassName:@"UserInformation"];

[query getObjectInBackgroundWithId:@"dIwnk9tbr0" block:^(PFObject *gameScore, NSError *error)
{
    gameScore[@"email_address"] = @"testkolang@y.com";
    [gameScore saveInBackground];

}];

But I have this kind of error. And the data on parse is not changed.

2014-03-12 18:08:06.036 AndroidiOsPushTest[3725:1803] Error: object not found for update (Code: 101, Version: 1.2.18)

回答1:


    PFQuery *query = [PFUser query];
    [query getObjectInBackgroundWithId:objectID block:^(PFObject *UserInfo, NSError *error) {

        if (!error) {

           [UserInfo setObject:self.userName.text forKey:@"username"];
           [UserInfo setObject:@"US" forKey:@"country"];

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



回答2:


Your issue looks like the one in : I can not update a record in Parse; Error: "object not found for update (Code: 101, Version: 1.2.16)"

Error code 101 in Parse means :

101: Object doesn't exist, or has an incorrect password.

First, you should check if your object exists and if the error is not null. Then, if these steps are successful, you should check for the ACL of the object : if you don't have permissions to edit it, you will be unable to save it and get the error 101.




回答3:


It relate to ACL, please check your dashboard for the data column "ACL"

The write should lock on specific user ID. you need change it from your dashboard to update its permission to

{"*":{"write":true,"read":true}}

You can check more detail on my reply in this




回答4:


From Parse.com (Hector Ramos)

    PFQuery *query = [PFQuery queryWithClassName:@"UserStats"];
[query whereKey:@"user" equalTo:[PFUser currentUser]];
[query getFirstObjectInBackgroundWithBlock:^(PFObject * userStats, NSError *error) {
  if (!error) {
    // Found UserStats
    [userStats setObject:newScore forKey:@"latestScore"];

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


来源:https://stackoverflow.com/questions/22348092/updating-saved-data-in-parse-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!