iOS - another thread needs to send reloadData to the mainthread

KaiserJohaan picture KaiserJohaan · Oct 27, 2011 · Viewed 8.4k times · Source

I got a separate thread that creates a UIView object, inserts it into the UITableView's data source and then call reloadData on the UITableView. However, since it is a separate thread, it cannot call reloadData directly, it needs to make the mainthread do it... but how do you tell the mainthread to do it?

Thanks

Answer

Can Berk Güder picture Can Berk Güder · Oct 27, 2011
[self.tableView performSelectorOnMainThread:@selector(reloadData)
                                 withObject:nil
                              waitUntilDone:NO];