IOSparsing如何从基于两个类的查询中检索对象?

我有两个类UserPostUser类有一个userType字段,我想从给定的userType检索所有的post,让我们把它们称为组x。 在Post类中,我有一个指向User类的指针。

我试图做一些事情,首先检索所有用户ID为我想要的用户types:

 PFQuery *queryUser = [PFQuery queryWithClassName:kFTUserClassKey]; [queryUser whereKey:kFTUserTypeKey equalTo:kFTUserTypeX]; [queryUser whereKey:kFTUserLocationKey nearGeoPoint:nearGeoPoint withinMiles:miles]; [queryUser findObjectsInBackgroundWithBlock:^(NSArray *usersTypeX, NSError *error) { if (!error) { NSMutableArray *objectIds = [[NSMutableArray alloc] init]; // Add ambassador ids into query for (PFObject *userX in usersTypeX) { [objectIds addObject:[PFObject objectWithoutDataWithClassName:kFTUserClassName objectId: userX.objectId]]; } } }]; 

然后我想基于这些objectIds查询,但我不知道如何查询这个数组,或者如果这是甚至正确的方式来做到这一点。 如何才能做到这一点?

Parse提供了查询中的matchesQuery方法,所以…

 PFQuery *innerQuery = [PFQuery queryWithClassName:@"User"]; [innerQuery whereKey:@"userType" equalTo:@"X"]; // fix with your real user type PFQuery *query = [PFQuery queryWithClassName:@"Post"]; [query whereKey:@"user" matchesQuery:innerQuery]; [query findObjectsInBackgroundWithBlock:^(NSArray *posts, NSError *error) { // posts are posts where post.user.userType == X }];