Scenario = I am trying to fetch data from parse and store that data into an array I can use anywhere in my view controller class.
Problem = When I run this below, Log 2 returns "(null)". The contents of "objects" seems like it doesn't want to leave the findObjects block. And it needs to otherwise the fetch was pointless.
PFQuery *messageQuery = [PFQuery queryWithClassName:@"Message"];
[messageQuery whereKey:@"receiverID" equalTo:[PFUser currentUser][@"userID"]];
[messageQuery findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
messageArray = objects;
NSLog(@"Log 1 = %@", messageArray);
}];
NSLog(@"Log 2 = %@", messageArray);
Question = Why is this happening? Or not happening?
I have tried putting the NSLog and the "messageArray = objects" inside of a dispatch_async and it still returns "(null)". What gives?