0
データを取り込もうとしているtableViewがあります。関数内の配列に値を代入しています。 searchWithLocation
の機能が終了するまで、すべてが保存されます。ログを見ると、データの順序が十分に速くならないように、注文と関係していると思います。それとも、それは理由ではない、私は本当に分かりません。NSMutable配列は、終了後にデータを保持しません。
- (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];
}
ログ:
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
私はtableViewCellを更新したい場合は、completionHandlerが起動し、その中でいくつかの更新メソッドを呼び出すまで待つ必要がありますか?申し訳ありませんが、私がしようとしていることが意味をなさない場合、私はウェブの背景から来ています。 – itsclarke
Ahh okay cool私はそれを理解した、私はちょうどあなたが言ったことを見直してそれを話さなければならなかった。どうもありがとう。 – itsclarke