Daily iOS
SwiftUI

Combine list-detail live coding

This is a 20-minute live coding exercise. Using only Combine, build a two-screen SwiftUI app that fetches a list from an API, shows it, and navigates to a detail screen when an item is tapped. How do you set up the view model and state to start?

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

Put a @Published state enum (idle/loading/loaded/failed) in an ObservableObject view model, have the view own it with @StateObject and call load from .task. The detail screen only displays the model it receives, so it has no view model.

Share a question