I have a table view which displays Facebook friend's data. Data is stored on Parse and I'm pulling it down and storing the data in "postArray" using the following query. I have used NSLog to check postArray object's and I am getting the desired results.
What happens is that I get sum of my data stored in postArray to be set to the appropriate labels and then some are just left empty. As I said, I did NSLog postArray and it gives me what I wanted. But when I go to set the data, it doesn't set all the data but just some.
Problem #1--> I need all of the data to be able to be accessible from the array and it's not letting me.
Problem #2 --> It is hit or miss whether it loads anything at runtime or not. If I log in and log out its a coin flip whether it will even load anything. I NSLog postArray and it seems it the array is empty sometimes. I know what you are thinking - "You got to give me something better than "sometimes", but I really can't. It's hit or miss.
Please help me out and tell me what's going on with it!
(and the dispatch_async makes no difference)
What I've been doing =
[[FBRequest requestForMyFriends] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
friendDict = result;
friendArray = friendDict[@"data"];
for (NSDictionary *friendObject in friendArray) {
friendIDs = [NSMutableArray arrayWithObjects:[friendObject objectForKey:@"id"], nil];
PFQuery *postQuery = [PFQuery queryWithClassName:@"Post"];
[postQuery whereKey:@"postedByID" containedIn:friendIDs];
[postQuery orderByAscending:@"createdAt"];
[postQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
postArray = objects;
[self.activityTableView reloadData];
});
}];
}
}
else {
//there are errors
}
}];