This question seems a bit complicated but it is very basic.
I have one table called X1:
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
:
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.