0

I'm trying to update an existing row in my Parse.com class from an iOS app. Upon doing so, I'm getting this error back from Parse:

This user is not allowed to perform the update operation on City. You can change this setting in the Data Browser. (Code: 119, Version: 1.9.1)

I have two Parse.com classes: City and Bar. The City class is read-only (it's a list of cities that won't change) and the Bar class is the class that users interact with (like adding comments, ratings, menu items, etc). Bar has a Pointer column on City and the permissions on Bar are all on for the public user.

Here's a snippet of code:

- (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];
  PFQuery *query = [PFQuery queryWithClassName:@"Bar"];
  self.bar = [query getObjectWithId:self.barId];
  self.bar.name = @"Foo";
  [self.bar saveInBackground];
}

Some notes about the snippet: I'm passing in the bar's ID from the previous view controller via segue. I also know this is running the Parse query on the main thread and it's going to block...I'm simply prototyping right now and this is meaningless code.

Upon running that snippet, I get the error listed above. As you can see in the code, I'm not changing the city value nor am I even including it in the query results. I don't understand why I would be getting this error. Any input would be greatly appreciated!

2
  • It seems you are going to have problems because you are not waiting for [query getObjectWithId:self.barId] to finish. So using self.bar before it's ready will likely fail. It may not be exactly your question, but I thought it may be useful for you. Commented Nov 7, 2015 at 6:01
  • It looks like this issue is due to me instantiating my City object using objectWithoutDataWithClassName. It seems that instantiating an object in this manner sets the dirty flag as true. So when I save my Bar it's also trying to save my City because it's dirty. But City is read-only and hence the error. Commented Nov 7, 2015 at 16:39

1 Answer 1

1

Try this code and see if the 2 NSLog messages appear in the order you expect:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    PFQuery *query = [PFQuery queryWithClassName:@"Bar"];
    //self.bar = [query getObjectWithId:self.barId];
    [query getObjectInBackgroundWithId:self.barId block:^(PFObject *result, NSError *error) {
        NSLog(@"query has finished.");
        self.bar = result[0];
    }];
    self.bar.name = @"Foo";
    NSLog(@"Now going to saveInBackground.");
    [self.bar saveInBackground];
}

And then try this, I think it may work, though I do not know all the details of your project:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    PFQuery *query = [PFQuery queryWithClassName:@"Bar"];
    //self.bar = [query getObjectWithId:self.barId];
    [query getObjectInBackgroundWithId:self.barId block:^(PFObject *result, NSError *error) {
        self.bar = result[0]; // or result; ??
        self.bar.name = @"Foo";
        [self.bar saveInBackground];
    }];
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer. Take a look at my comment to my original question. Turns out using objectWithoutDataWithClassName sets the dirty flag (which is what I was using to generate my City object). Now that I'm pulling the values from Parse (rather than generating them myself) it all works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.