I have a tableView that I'm trying to populate with data. I'm assigning values to an array within a function. Everything is saved up until up until it leaves the searchWithLocation function. Looking at the logs it makes me think that it has to do with ordering, like I'm not getting my data populated quick enough. Or maybe that's not the reason, I really have no idea.
- (void)viewDidLoad {
[super viewDidLoad];
venueName = [[NSMutableArray alloc] init];
[YLPClient authorizeWithAppId:@"sdgsfgfgfg"
secret:@"aegsgdgdfs"
completionHandler:^
(YLPClient *client, NSError *error) {
// Save your newly authorized client
self.client = client;
[self.client searchWithLocation:@"Chicago"
completionHandler:^
(YLPSearch *search, NSError *error) {
for (YLPBusiness *business in search.businesses) {
[venueName addObject:business.name];
}
NSLog(@"I return results: %lu", (unsigned long)[venueName count]);
}];
NSLog(@"I return 0: %lu", (unsigned long)[venueName count]);
}];
}
...
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
NSLog(@"number of rows in section: %lu", (unsigned long)[venueName count]);
return [venueName count];
}
The logs:
2017-09-02 14:46:39.708 whatever[67890:8535793] number of rows in section: 0
2017-09-02 14:46:39.714 whatever[67890:8535793] number of rows in section: 0
2017-09-02 14:46:39.715 whatever[67890:8535793] number of rows in section: 0
2017-09-02 14:46:40.448 whatever[67890:8535846] I return 0: 0
2017-09-02 14:46:41.174 whatever[67890:8535846] I return results: 20