Daily iOS
UIKit

viewDidLoad and network requests

A teammate kicks off a network request directly in viewDidLoad and updates the UI when the response arrives. What problems can this cause?

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

viewDidLoad runs once per instance while the view isn't on screen yet, so returning to the screen doesn't refresh, and a response that lands after the screen is gone is wasted or can crash.

Share a question