I'm having issues getting data from the pointers within objects I get from from my parse query. I use the include key on the query, but having issues getting the include key information from the returned objects array. I created a for loop to iterate over the results but not sure how to store them back into an array. Here's my code below:
- (void) loadUsersPFUserIsFollowing
{
//Retrieving PFUser Curren Users followers and storing in Array
PFQuery *queryFollowingCount = [PFQuery queryWithClassName:@"Activity"];
[queryFollowingCount whereKey:@"type" equalTo:@"follow"];
[queryFollowingCount whereKey:@"fromUser" equalTo:[PFUser currentUser]];
//Access the the user following informatioin
[queryFollowingCount includeKey:@"toUser"];
//[queryFollowingCount setCachePolicy:kPFCachePolicyCacheThenNetwork];
[queryFollowingCount findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[HUD hide:YES];
if (!error) {
searchResultsArray = [[NSArray alloc] initWithArray:objects];
NSLog(@"%@", objects);
for (PFObject * postObject in objects) {
PFObject *postAuthor = [postObject objectForKey:@"toUser"][@"username"];
NSLog(@"retrieved related Post Author: %@", postAuthor);
}
[self.tableView reloadData];
} else {
NSLog(@"Something went wrong");
NSLog(@"%@", error);
}
}];
}