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?Acey– Acey2014-08-23 20:55:10 +00:00Commented Aug 23, 2014 at 20:55
-
No. I gather all the objects in viewdidload for my mapView. And display all the annotations.Michael Chen– Michael Chen2014-08-23 21:16:54 +00:00Commented Aug 23, 2014 at 21:16
Add a comment
|
1 Answer
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.
1 Comment
Sandip Subedi
Looks like it doesn't work anymore. It says "Expected expression in container literal"