如何使用解析检索公会中的所有公会成员?
这是我的代码:
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);
}];
我的日志:
有0个公会成员。错误:(空)
connectedGuild是一个指向公会类的指针,我存储了所有的公会。
答案 0 :(得分:1)
PFUser
类的查询必须以稍微不同的方式实例化。试试这个:
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);
}];
有关详细信息,请访问Parse.com网站: https://www.parse.com/questions/get-pfuser-in-pfquery-using-ios-api