dimanche 28 juin 2015

Query PFRelation of blocked users

I'm trying to query the 'friend' relation while excluding any friends that have blocked the user (which is stored as a relation<_user>) on the friends user with a relation to the user they are blocking (potentially the user checking their friends). I tried querying like below, but it isn't excluding the record like I would think:

[SVProgressHUD showWithStatus:@"Loading ..."];

[friends removeAllObjects];

PFRelation *friendRelation = [[PFUser currentUser] objectForKey:@"friendsRelation"];
if (friendRelation)
{
PFQuery *friendsQuery = [friendRelation query];
    [friendsQuery orderByAscending:@"firstname"];
    [friendsQuery whereKey:@"disabled" notEqualTo:[NSNumber numberWithBool:YES]];
    [friendsQuery whereKey:@"Blocked" notEqualTo:[PFUser currentUser]];
[friendsQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
 {
     if (!error)
     {
         friends = [objects mutableCopy];
         [self.myTableView reloadData];
         [SVProgressHUD dismiss];
     }
     else
     {
         [SVProgressHUD showErrorWithStatus:@"Loading failed. Please try again."];
     }
 }];
}
else
{
    [SVProgressHUD dismiss];
}

Is there a way to accomplish what I am trying to do?

Aucun commentaire:

Enregistrer un commentaire