Reputation: 35
I have a class on Parse.com called "Hospital", which has a few rows on it. I want to query all the rows in this object, and then selectively delete some of them.
I figure I need to cycle through the object, gathering the objectIDs, and then look at the row associated with each ID to figure out which ones should be deleted. I can't find how to do this anywhere. I've tried this:
PFQuery *query = [PFQuery queryWithClassName:@"Hospital"];
But this returns an object with 0 objects inside it, when there is definitely a row in the Parse.com database.
Once I get this part working, and get objectIDs, it seems I can delete a row with the following:
PFObject *testObject = [PFObject objectWithoutDataWithClassName:@"Hospital" objectId:@"NMZ8gLj3RE"];
[testObject deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded){
NSLog(@"BOOOOOM"); // this is my function to refresh the data
} else {
NSLog(@"DELETE ERRIR");
}
}];
Upvotes: 0
Views: 2246
Reputation: 1864
PFQuery *query = [PFQuery queryWithClassName:@"Hospital"];
[query findObjectsInBackgroundWithBlock:^(NSArray *hospitals, NSError *error) {
if (!error)
{
for (PFObject *hospital in hospitals)
{
if ([hospital.objectId isEqualToString:@"NMZ8gLj3RE"])
{
[hospital deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded){
NSLog(@"BOOOOOM"); // this is my function to refresh the data
} else {
NSLog(@"DELETE ERRIR");
}
}];
}
}
}
else
{
NSLog(@"%@",error);
}
}];
Upvotes: 2