1

This question seems a bit complicated but it is very basic.

I have one table called X1:

enter image description here

Then I have another table called X2. This table has a column eventId which is a pointer (not Id) to table X1 as you can see in third column JJYa3y2gVb:

enter image description here

Now I want to create a query inside queryfortable method. This must return X1 but obtain which object's InvitedUser in X2 is equal to current user. To do this in viewDidLoad I already query which objects are in X2 equal to current user and save in NSMutableArray called _inviteList:

PFQuery *query = [PFQuery queryWithClassName:@"X2"];
[query whereKey:@"invitedUser" equalTo:[PFUser currentUser]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (!error) {
        // The find succeeded.
        NSLog(@"Successfully retrieved %lu scores.", (unsigned long)objects.count);
        // Do something with the found objects
        for (PFObject *object in objects) {

            [_inviteList addObject:[object objectForKey:@"eventId"]];

        }
        NSLog(@"Friends invited === %ld",_inviteList.count);
    } else {
        // Log details of the failure
        NSLog(@"Error: %@ %@", error, [error userInfo]);
    }
}];

Now I have a pointer array of X1 (eventId column). Then I need to get the rows that this pointer array contains:

    query = [PFQuery queryWithClassName:@"X1"];
    [query whereKey:@"????" containedIn:_inviteList];
    return query;

I don't want to say key because I am not looking for keys. _inviteList already contain an array of X1. I just want to say return where objectId in _inviteList is equal to object id in X1. Something like this

    [query whereKey:@"objectId" containedIn:_inviteList.objectId];

But of course this is not working. Appreciate if anyone can help me with this.

Bernard
  • 4,240
  • 18
  • 55
  • 88
  • Have you tried `[query whereKey:@"objectId" containedIn:_inviteList]` ? – Paulw11 Sep 18 '15 at 07:43
  • If you just use a standard tableview instead of a PFQueryTableView then you can simply call the `PFObject` class method `fetchAllInBackground:block` passing your array. You are going to struggle to build a query against X1 to do what you want because you don't have a relationship from X1 to X2 – Paulw11 Sep 18 '15 at 07:53
  • @Paulw11 Yes but it says objectId is not defined for NSMutableArray – Bernard Sep 18 '15 at 12:38
  • As I said, I don't think you can do what you want with the data structure you have. I would just use a straight tableview. PFQueryTableViewControlller often isn't worth the trouble – Paulw11 Sep 18 '15 at 19:58

0 Answers0