Beginning Core Data · Challenge: Fixing Sorting Issues | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7104-beginning-core-data/lessons/11

Using DispatchQueue.main.async{}
When is it necessary to update view elements in dispatchqueue.main.async and when not?
For eg.,
searchBar.text = nil
In the tutorial code, this was not inside main.async, is there any logic to know which code to run on DispatchQueue.main.async?

You always need to update all your view elements on the main thread. The UI elements aren’t thread-safe and will become corrupted if you attempt to update them from the background.

1 Like

Hi thanks for the response, watched the ios beginner courses. It was clarified there :slight_smile:

Awesome! Glad to hear you got clarification!