Q:

iOS Parse SDK: How to count elements from one-to-many relationship

Description = I have a project that allows users to post things. These posts will be displayed in a tableView, (the comments will not be shown in this tableView). When a user presses a post, they will segue to a screen where they can post a comment. In the tableViewCell there will be a label like "(0) comments" to display how many comments belong to the post. 
2 Queries happen. One query to populate the tableView, and another to query the amount of comments from each post at each indexPath.
Desired Result = If there are 5 comments on a post, to be able to return how many comments where made on each post so I can .count them into a string to say, "(5) Comments".
Problem = I'm not sure how to query for the results of a query, or if that is even what is supposed to happen. I'm not even sure if this is going right, please help someone who is knowledgable. I attached what I have done (not a copy and paste i typed all of that [so if something isn't right or there was a typo, please do not respond telling me that that was the problem with the code]).
What I have done =
-viewDidLoad...

PFQuery *postQuery = [PFQuery queryWithClassName:@"Post"];
    [userQuery whereKey:@"postedByID" equalTo:selectedUserID];
    [userQuery orderByDescending:@"createdAt"];

    [userQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

        tableArray = objects;
        [self.tableView reloadData];

    }];

-cellForRowAtIndexPath...

PFObject *post = [tableArray objectAtIndex:indexPath.row];

PFFile *imgFile = post[@"postPicture"];
[imgFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {

    cell.picture.image = [UIImage imageWithData:data];

}];

NSString *dateAndTime = [NSString stringWithFormat:@"%@ %@", post[@"postDate"],post[@"postTime"]];

cell.categoryLabel.text = post[@"category"];
cell.subCategoryLabel.text = post[@"subCategory"];
cell.dateLabel.text = dateAndTime;
cell.descriptionLabel.text = post[@"description"]];

//below is where my headaches are coming from

PFQuery *commentsQuery = [PFQuery queryWithClassName:@"Comment"];    

//WHAT DO I DO HERE? (this probably isn't right, but I feel like it should be)
[commentsQuery whereKey:@"parentID" containedIn:[tableArray objectAtIndexPath:indexPath.row][@"objectId"];

[commentsQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

        NSLog(@"%@", objects);

}];

This returns an empty log.
I know for a fact that there are multiple comments in relation to some of the posts, yet still returns nothing. I believe this is because my commentsQuery isn't right, or something. I dunno, please help someone. 

A:

If I understand correctly your case, you should try with:
[commentsQuery whereKey:@"parentID" equalTo:[tableArray objectAtIndexPath:indexPath.row][@"objectId"];

since you are querying all of the comments belonging to a specific post.
containedIn would allow you to get all of the comments belonging to a given set of posts.

