iosparse-platformcontainspfquery

Parse Query ContainsString returns Invalid response


I am using a PFQuery in my iOS app to search for group names that already exist in a class on Parse.com. For my code, I have:

PFQuery *groupQuery = [PFQuery queryWithClassName:@"Group"];
    if ([groupQuery whereKey:@"GroupName" containsString:self.theView.signUpView.additionalField.text]) {
        NSLog(@"It Contains It %@", self.theView.signUpView.additionalField.text);
    }

The issue I am having is that it ALWAYS shows it contains it. For example, the name of a group I tried adding was Bazinga The current group names are YWAM YWAM Kona CRICS Teachers. Yet, it always showed that the query already contained a GroupName of Bazinga. What is going on here?


Solution

  • You need to execute the query

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