Parse Query ContainsString返回无效响应

时间:2016-12-08 16:27:27

标签: ios parse-platform contains pfquery

我在我的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。这是怎么回事?

1 个答案:

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