【发布时间】:2014-10-12 12:31:17
【问题描述】:
我正在尝试使用 Parse 检索 UITableView 中的单元格数。
调用返回的速度比后台任务完成的速度快,因此单元格的数量等于零。
代码如下:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
__block int rows;
PFQuery *query = [PFQuery queryWithClassName:@"bills"];
[query whereKey:@"houseId" equalTo:@1];
[query countObjectsInBackgroundWithBlock:^(int count, NSError *error) {
if (!error) {
rows = count;
NSLog(@"in block = %d",rows);
} else {
rows = 0;
}
}];
NSLog(@"out of block = %d",rows);
return rows;
}
【问题讨论】:
标签: ios objective-c uitableview parse-platform