tableView refresh issue

I have an which subscribes to an external event, when it receives data it adds it to the table view data source. im trying to refresh the screen when new data is added to the table.
I have tried below 2 approaches to update table in UI and both of them doesnt show latest data on the screen unless i click on the screen somewhere.

        public void updateTable(){
        try {
            if (tableView() != null) {
                NSIndexPath path = NSIndexPath.indexPathForRowInSection(tableDataSource.getListSize() - 1, 0);
                NSArray paths = NSArray.arrayWithObject(path);
                tableView().insertRowsAtIndexPathsWithRowAnimation(paths, UITableViewRowAnimation
        } catch (Exception e) {

Above method was taken from the RSS feed MOE sample
I have also tried to refresh the whole table with

//below code does not refresh the screen unless i click on in

I’m looking for a working method/code snippet to update my tableview when i add data to it.

Thank you in advance


1 Like

here is the video of the issue. As mentioned earlier, table data gets updated but tableview does not refresh till user clicks on the UI

Check you are calling tableView().reloadData() or tableView().insertRowsAtIndexPathsWithRowAnimation(…) from an UI thread

Hi Eugene,

I’m calling those in the main UI thread.

looks like i had to run it in the main thread explicitly, thats strange because it worked without any issues when i updated the tableview in another view. Below code will help to update it in the main thread

Globals.dispatch_async(Globals.dispatch_get_main_queue(), () -> {
		if (NSThread.isMainThread_static()) {
			System.out.println("Running is main thread");
			System.out.println("#B not main thread");