I have UITableViewController as the RootViewController. I need to add rows to the table depending on data I get from another thread which I initiate from the RootViewController’s thread. When I retun back from other thread to my RootViewController’s thread I have the updated data, But I can’t update the TableView. I called the [self.tableview reloadData]; method but that doesnt seem to work. I also tried the [self.tableview setNeedsDisplay] call but with no success. How do I update the TableView with new data?
In my RootViewController Class I have: - (void) reload { for(int i=0;i<[camDetails count];i++) { cCameraInformation *obj = [[cCameraInformation alloc] init]; obj = [camDetails objectAtIndex:i]; NSString *tString = [[NSString alloc] initWithFormat: @' Remote %s %s',[obj->sCameraid UTF8String],[obj->sCameraid UTF8String]]; [tableEntry addObject:tString]; } [self.tableView reloadData]; }
Then there is a receive class thread which is continuously receiving data. Its base class is NSObject. So, I used the Application delegate class ( which has an instance of RootViewController class ) to call this reload data method of the RootViewController class in my receive thread.
I am unable to invoke the above method using performSelectorOnMainThread.
hey are you sure you are updating the table view display / reloading tableview on the main thread? i faced the same problem, the data was in there but until user scrolls, tableview was not updated
upon googling i came to know you need to call the reloadData method on the main ui thread
code example below: