I'm trying to query for objects based on the User who posted the PFObject being in the current user PFRelation "friendship". I was wondering if you can use a PFRelation as you would a NSArray and do something similar to this..
@"user" is a pointer to the PFUser who posted the PFObject.
PFQuery *query = [PFQuery queryWithClassName:TV_TIMELINE_POSTS];
[query includeKey:@"user"];
[query whereKey:@"user" containedIn:[PFUser currentUser][@"friendship"]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[self.objectArray addObjectsFromArray:objects];
}];
Or if the only way to achieve this would to be to fill an NSArray with the PFUsers from the PFRelation, and then query with the results
PFRelation *relation = [[PFUser currentUser] relationForKey:@"friendship"];
PFQuery *relationQuery = [relation query];
[relationQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
self.followingArray = [[NSMutableArray alloc] initWithArray:objects];
}];
PFQuery *query = [PFQuery queryWithClassName:TV_TIMELINE_POSTS];
[query includeKey:@"user"];
[query whereKey:@"user" containedIn:self.followingArray];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[self.objectArray addObjectsFromArray:objects];
[self.collectionView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
[self.refreshControl performSelectorOnMainThread:@selector(endRefreshing) withObject:nil waitUntilDone:NO];
_isLoading = NO;
}];
Thanks in advance, Evan