0

I am trying to run this query however it is returning no objects. Any help?

    for (int arrayIndex=0; arrayIndex<[self.cards count]; arrayIndex++)
{
    NSString *senderId = [[deck objectAtIndex:arrayIndex]objectForKey:@"SenderId"];
    [list_of_sender_ids addObject:senderId];
}
PFQuery *query = [PFQuery queryWithClassName:@"User"];
[query whereKey:@"facebook_id" containedIn:list_of_sender_ids];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

1 Answer 1

2

A couple of things that could be going wrong right off the bat: First of all, to query the user class, you shouldn't use

PFQuery *query = [PFQuery queryWithClassName:@"User"];

But instead,

PFQuery *query = [PFUser query];

Assuming your User class still returns PFUser objects. Another thing to make sure is right is the @"Facebook_id" key, and confirm in Parse that this is a top level key that you can see on your Parse User objects. Lastly, make sure @"SenderId" is also the right key on the objects in deck, since you seem not to be querying based on the same key that could cause the issue.

Sign up to request clarification or add additional context in comments.

4 Comments

@"facebook_id" is the correct key name (column name) in my User table and @SenderId is a the right key on the deck object. However wouldn't the problem be that all the fields under the facebook_id column in the users table arent being checked accordingly with the array of sender_ids?
I'm not sure what you are asking here, but if those are the correct keys, then according to parse.com/docs/ios/api/Classes/PFQuery.html#//api/name/…: this should work. Did you try changing to a [PFUser query]?
YES i just tested it again after changing it to [PFUser query] and it works! Thank you! Would you mind explaining why that was the issue?
Parse is pretty picky about it's queries, and the User class is somewhat special. From what I understand, this is just the way to generate a query on that special class.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.