0

I have a Parse object called annotation with a title class that I store in the Parse database. When the user clicks a certain button, I want to be able to remotely delete the row of the annotation object that has a specified "title". How can I do this? I've seen code that declares "var query = new Parse.Query(myObject);" But I get an error trying to do this.

2
  • Are you displaying your results in. UITableView? Commented Aug 23, 2014 at 20:55
  • No. I gather all the objects in viewdidload for my mapView. And display all the annotations. Commented Aug 23, 2014 at 21:16

1 Answer 1

1

If you only have the title (i.e., not the object) use a query to determine the specific object (row) you want to delete, then delete it. E.g.:

PFQuery *query = [PFQuery queryWithClassName:@"MyClassName"];
[query whereKey:@"title" equalTo:theTitleString];
[query getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
  if (object) {
        [object deleteInBackground];
  } else {
    NSLog(@"Unable to retrieve object with title %@.", theTitleString);
  }
}];

The above assumes there is only one object with the given title.

You can also use [object deleteEventually]; in place of the deleteInBackground method which will work even if the device does not have an internet connection at the time the user wants it to be deleted.

Sign up to request clarification or add additional context in comments.

1 Comment

Looks like it doesn't work anymore. It says "Expected expression in container literal"

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.