I'm trying to query a PFRelation of the current user of the app to load a table view showing all of the users friends. Each user is saved under a class called "User" when they first use the app and once they add a friend that friend is added to the column "friendsRelation" for the user. I'm using this code i got got from this link and nothing is returned from the query.
PFQuery *query = [PFQuery queryWithClassName:@"User"];
[query whereKey:@"friendsRelation" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"An error occurred fetching friends");
}
else {
[self.friends addObjectsFromArray:objects];
[self.tableView reloadData];
}
}];
Try this:
PFRelation *relation = [[PFUser currentUser] relationForKey:@"friendsRelation"];
PFQuery *query = [relation query];
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
// results contains all friends of current user
}];