4

I have many threads calling UITableView's reloadData method concurrently. Do I actually have to put a @synchronized block around it?

ikevin8me
  • 4,253
  • 5
  • 44
  • 84

2 Answers2

5

reloadData, like any other method on a view, should only be called from the main thread only. So you don't need @synchronized because only one thread should be there at a time.

If you're on a background thread and you want the table view to reload, use dispatch_async to make sure the reload happens on the main thread:

dispatch_async(dispatch_get_main_queue(), ^{
    [myTableView reloadData];
});
benzado
  • 82,288
  • 22
  • 110
  • 138
5

You shouldn't call reloadData from threads other than the main thread.

See this similar question:

iOS - another thread needs to send reloadData to the mainthread

Community
  • 1
  • 1
TomSwift
  • 39,369
  • 12
  • 121
  • 149