Parse IOS deleting all objects wherekey = objectID

ios, objective-c, parse-platform

Solution

Try this,

 PFQuery *query = [PFQuery queryWithClassName:@"messages"];
 [query whereKey:@"UserID" equalTo:@"user"];
 [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
 if (!error) {
     // The find succeeded.
     NSLog(@"Successfully retrieved %d scores.", objects.count);
     // Do something with the found objects
     for (PFObject *object in objects) {
         [object deleteInBackground];
     }
 } else {
     // Log details of the failure
     NSLog(@"Error: %@ %@", error, [error userInfo]);
 }
}];

Update

replace

for (PFObject *object in objects) {
    [object deleteInBackground];
}

with

[PFObject deleteAllInBackground:objects];

thanks mikewoz for the update.

Problem

Is there an easy way to delete all objects within a particular class (i.e. messages) which satisfy a particular condition, such as "UserID" = user, so that all of the rows within my message class associated with a particular user will be deleted?

Original source