Hello to everyone in the query I posted I'm trying to retrieve all of the posts and PfUserCurrent all posts of people who have shared a friendship with PfUserCurrent.
The query works fine but I have only one problem, the query shows me all the posts of Friends of the CurrentUser but does not show me those sent by the CurrentUser ... I've tried several attempts but I could not fix this ... Can you explain where I'm wrong?
-(void)QueryForPost {
PFQuery *QueryForFriend=[PFQuery queryWithClassName:@"Friendships"];
[QueryForFriend whereKey:@"To_User" equalTo:[PFUser currentUser]];
[QueryForFriend whereKey:@"STATUS" equalTo:@"Confirmed"];
PFQuery *QueryYES = [PFQuery queryWithClassName:@"Post"];
[QueryYES whereKey:@"FLASH_POST" equalTo:[NSNumber numberWithBool:YES]];
[QueryYES whereKey:@"UserSelected" equalTo:[PFUser currentUser]];
PFQuery *QueryNO = [PFQuery queryWithClassName:@"Post"];
[QueryNO whereKey:@"FLASH_POST" equalTo:[NSNumber numberWithBool:NO]];
[QueryNO whereKey:@"Author" matchesKey:@"From_User" inQuery:QueryForFriend];
PFQuery *query = [PFQuery orQueryWithSubqueries:@[QueryYES,QueryNO]];
[query includeKey:@"Author"];
[query orderByDescending:FF_CREATEDAT];
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
if (!error) {
NSLog(@"%@", results);
ArrayforPost = [[NSMutableArray alloc] init];
for (PFObject *object in results) {
[ArrayforPost addObject:object];
}
[self.FFTableView reloadData];
}
}];
}
[QueryForFriend includeKey:@"Da_User"]under yourQueryForFriend queries. This might be problem ifDa_Useris a pointer[query orderByDescending:FF_CREATEDAT];whereFF_CREATEDATmight be not match with keycreatedAtinPOSTclass. IsArrayforPosta datasource ofFFTableView???