Daily iOS
Concurrency

Main thread and UI

In a UIKit screen you set label.text = result inside a network response callback, and sometimes the screen updates late or not at all. What's causing that?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

The URLSession callback arrives on a background queue, so you touched the UI from a background thread. UIKit isn't thread safe and rendering is tied to the main run loop, so updates get dropped, delayed, or crash.

Share a question