Objective c 使用Parse.com查询数组中的2个值

Objective c 使用Parse.com查询数组中的2个值,objective-c,ios,parse-platform,Objective C,Ios,Parse Platform,我需要查询parse.com以检查数组中是否存在2个指定值 文件指出: 您可以提供多个约束,只有当对象与所有约束匹配时,它们才会出现在结果中。换句话说,这就像约束的and 根据我的经验,情况并非如此 我这样问: NSString *user1 = [self.users objectAtIndex:0]; NSString *user2 = [self.users objectAtIndex:1]; NSLog(@"User 1: %@", user1); NSLog(@"User 2: %@

我需要查询parse.com以检查数组中是否存在2个指定值

文件指出: 您可以提供多个约束,只有当对象与所有约束匹配时,它们才会出现在结果中。换句话说,这就像约束的and

根据我的经验,情况并非如此

我这样问:

NSString *user1 = [self.users objectAtIndex:0];
NSString *user2 = [self.users objectAtIndex:1];

NSLog(@"User 1: %@", user1);
NSLog(@"User 2: %@", user2);

PFQuery *gameQuery = [PFQuery queryWithClassName:@"GameObject"];
[gameQuery whereKey:@"users" equalTo:user1];
[gameQuery whereKey:@"users" equalTo:user2];

NSArray *gameObjects = [gameQuery findObjects];

NSLog(@"gameObjects: %@", gameObjects);
2012-04-21 14:12:23.656 Cargo[5435:707] User 1: 689XXX62
2012-04-21 14:12:23.658 Cargo[5435:707] User 2: 51XXXX994
[query whereKey: @"users" 
    containedIn: [NSArray arrayWithObjects: user1, user2, nil]];
我的日志会这样写:

NSString *user1 = [self.users objectAtIndex:0];
NSString *user2 = [self.users objectAtIndex:1];

NSLog(@"User 1: %@", user1);
NSLog(@"User 2: %@", user2);

PFQuery *gameQuery = [PFQuery queryWithClassName:@"GameObject"];
[gameQuery whereKey:@"users" equalTo:user1];
[gameQuery whereKey:@"users" equalTo:user2];

NSArray *gameObjects = [gameQuery findObjects];

NSLog(@"gameObjects: %@", gameObjects);
2012-04-21 14:12:23.656 Cargo[5435:707] User 1: 689XXX62
2012-04-21 14:12:23.658 Cargo[5435:707] User 2: 51XXXX994
[query whereKey: @"users" 
    containedIn: [NSArray arrayWithObjects: user1, user2, nil]];

2012-04-21 14:12:24.614货物[5435:707]游戏对象:{
用户=(
8xx66,
51XX994
);
}
该查询显然是在向我返回一个匹配任一约束的对象数组。 不是两个


如何解决此问题?

来自解析头文档:

/*!
  Add a constraint to the query that requires a particular key's object to be contained in the provided array.
 @param key The key to be constrained.
 @param array The possible values for the key's object.
 */
- (void)whereKey:(NSString *)key containedIn:(NSArray *)array;
你会这样称呼它:

NSString *user1 = [self.users objectAtIndex:0];
NSString *user2 = [self.users objectAtIndex:1];

NSLog(@"User 1: %@", user1);
NSLog(@"User 2: %@", user2);

PFQuery *gameQuery = [PFQuery queryWithClassName:@"GameObject"];
[gameQuery whereKey:@"users" equalTo:user1];
[gameQuery whereKey:@"users" equalTo:user2];

NSArray *gameObjects = [gameQuery findObjects];

NSLog(@"gameObjects: %@", gameObjects);
2012-04-21 14:12:23.656 Cargo[5435:707] User 1: 689XXX62
2012-04-21 14:12:23.658 Cargo[5435:707] User 2: 51XXXX994
[query whereKey: @"users" 
    containedIn: [NSArray arrayWithObjects: user1, user2, nil]];
如PFQuery.h所述 使用此可用方法。这是为了确保指定数组中的每个对象都必须存在

- (void)whereKey:(NSString *)key containsAllObjectsInArray:(NSArray *)array;
例子
不。。。如果我需要找到其中一个,这个方法就行了。我需要找到两个。对不起,我误解了你的问题。看起来你需要一个“和”版本的orQueryWithSubqueries:我会给解析人员发一封电子邮件,他们很容易接受。