我在我的iOS应用中使用PFQuery
来搜索Parse.com上类中已存在的组名。对于我的代码,我有:
PFQuery *groupQuery = [PFQuery queryWithClassName:@"Group"];
if ([groupQuery whereKey:@"GroupName" containsString:self.theView.signUpView.additionalField.text]) {
NSLog(@"It Contains It %@", self.theView.signUpView.additionalField.text);
}
我遇到的问题是它总是显示它包含它。例如,我尝试添加的论坛名称为Bazinga
当前论坛名称为YWAM
YWAM Kona
CRICS Teachers
。然而,它始终显示查询已包含Bazinga的GroupName。这是怎么回事?
答案 0 :(得分:2)
您需要执行查询
PFQuery *groupQuery = [PFQuery queryWithClassName:@"Group"];
[groupQuery whereKey:@"GroupName" containsString:self.theView.signUpView.additionalField.text])
[groupQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error)
{
if (error == nil){
// Great! objects should only have the Group objects that contain thetext
}
else{
// oops...check the error
}
}];