I'm trying to print users loaded of Parse, but can't find the error in the code.
-(void)viewDidLoad {
[super viewDidLoad];
PFQuery *query = [PFQuery queryWithClassName:@"User"];
[query orderByAscending:@"username"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error: %@, %@", error, [error userInfo]);
}
else {
self.allUsers = objects;
NSLog(@"%@",self.allUsers);
[self.tableView reloadData]; }
}];
}
I believe [self.tableView reloadData] has to run on the main thread in order to update from inside this block.