我正在开发一个应用程序,我必须从 JSON 获取数据并在 UITableView 中显示。正在后台获取数据。但它似乎进入了无限循环。
任何帮助将不胜感激。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
queue = dispatch_queue_create("com.events.app", NULL);
dispatch_async(queue, ^{
[self load];
//Need to go back to the main thread since this is UI related
dispatch_async(dispatch_get_main_queue(), ^{
// store the downloaded image in your model
Events *evObj = [eventsArray objectAtIndex:[indexPath row]];
NSLog(@"evObj = %@",evObj);
cell.textLabel.text = evObj.eName;
cell.detailTextLabel.text = @"Detailed Text";
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil]
withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
});
});
// Configure the cell...
return cell;
}