In my iOS5 application, I have UITableView that would display cells based on NSString values stored in progressLabelArray. I have registered a call back from my lower layers and I receive them in a C function from where I manage to call the UI update method through a reference to self.
static void callback_handler(int nCode) {
[refToSelf updateProgressView:nCode];
}
-(void) updateProgressView:(int32_t) nCode
{
NSString *status = nil;
status = [self progressUpdateToString:nCode];
[self.progressLabelArray insertObject:status atIndex:0];
[self.progressTableView reloadData];
[self.progressTableView setNeedsDisplay];
}
I guess, since the callbacks are coming on the same (UI thread), performSelectorOnMainThread may not be required.
My problem is that the table view only gets refreshed when the entire operation is complete, showing the last call back values. Is there a way by which I can force the UI to refresh after every callback? The callbacks coming might be relatively fast.
Resolved the issue by running the progress code in a separate thread. The callbacks come on a seprate thread and there I update my main thread (UI thread). I guess the UI thread was not getting any cycles to update the UI.