Do I need to use @synchronized when calling the reloadData UITableView method?

I have many threads calling the UloadableView reloadData method at the same time. Do I really have to put an @synchronized block around it?

+4
source share
2 answers

You should not call reloadData from threads other than the main thread.

See this similar question:

iOS - another thread should send reloadData to mainthread

+5
source

reloadData , like any other method in a view, should only be called from the main thread . Therefore, you do not need @synchronized , because there should only be one thread.

If you are in the background thread and want to reload the table view, use dispatch_async to make sure that the reboot occurs in the main thread:

 dispatch_async(dispatch_get_main_queue(), ^{ [myTableView reloadData]; }); 
+5
source

Source: https://habr.com/ru/post/1438490/


All Articles