我在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。这里发生了什么?

最佳答案

您需要执行查询

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
            }
        }];

07-26 07:07