how to print users of Parse in Objective C?

40 views Asked by At

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];  }

    }];

}
1

There are 1 answers

0
Rod On BEST ANSWER

I believe [self.tableView reloadData] has to run on the main thread in order to update from inside this block.

dispatch_async(dispatch_get_main_queue(), ^{

    [self.tableView reloadData];
});