I am loading data into my UITableViewCell one at a time in the following method
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
_anIterationCounter++;
if (_anIterationCounter==_currentCount) {
if ((_currentCount+1)<=[_allTrains count]&&(_currentCount+1)<=5) {
_currentCount++;
_anIterationCounter=0;
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0);
dispatch_async(queue, ^{
[tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES]; //call apis here
});
}
}
the "_iterationCount" variable is initialised to be 0 in the beginning. Data is loaded from the array [_allTrains objectAtIndex:_currentCount]
and I only want to show 5 cells atmost.
But my program has a further step where a didSelectRowAtIndexPath
method exists.
But the control doesn't go into the delegate function until all the cells are done loading. How will I resolve this issue?