0

how do i retrieve all the guildmembers in your guild using parse?

Here is my code:

PFUser *currentuser = [PFUser currentUser];
PFQuery *query = [PFQuery queryWithClassName:@"User"];
[query whereKey:@"connectedGuild" equalTo:currentuser[@"connectedGuild"]];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    NSLog(@"There are %d guildmembers. Error:%@", comments.count, error);
}];

My log:

There are 0 guild members. Error:(null)

connectedGuild is a pointer to a guild class where i store all the guilds.

Dridia
  • 183
  • 15

1 Answers1

1

Queries of the PFUser class must be instantiated a little differently. Try this:

PFUser *currentuser = [PFUser currentUser];
PFQuery *query = [PFUser query];
[query whereKey:@"connectedGuild" equalTo:currentuser[@"connectedGuild"]];
[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    NSLog(@"There are %d guildmembers. Error:%@", comments.count, error);
}];

For more information, see the Parse.com website here: https://www.parse.com/questions/get-pfuser-in-pfquery-using-ios-api

Ryan Kreager
  • 3,571
  • 1
  • 20
  • 35