SwiftUI interview questions: how each answer is scored
By Mike Salari. Staff mobile engineer · 500+ technical interviews from the hiring side.
This page is for iOS engineers going into a senior SwiftUI round. You get ten questions as they are asked out loud, what gets scored, what a strong answer covers, follow-ups that change the conditions, and the weak answers. Answers use Observation (@Observable, iOS 17 and later) as the current model, and mention ObservableObject only as the older API you will still meet in existing code.
Who this is for
Senior and staff iOS engineers who ship SwiftUI and need to explain it under pressure: who owns each piece of state, why a view updates or does not, what identity decides, and which async result is allowed to reach the screen.
In a SwiftUI round a clean definition tells me almost nothing, because definitions are everywhere. A specific bug you shipped and fixed tells me you have used it. Lead with the bug, then the rule.
A second set on identity, state ownership, Observation and performance, each with the trap and the follow-up, is in the SwiftUI guide on Mobile Interview Room.
The questions
1. "This model has isLoading, hasError and isSubmitting. What would you change?"
What is scored: modelling state so impossible combinations cannot exist.
A strong answer covers:
- Three booleans allow eight combinations, and some are nonsense, such as loading and failed at once.
- One enum for the workflow phase forbids them by construction.
- SwiftUI Under Load asks four questions before choosing storage: what is the source of truth, how long does it live, who may change it, does it persist. The property wrapper is the last decision.
@MainActor @Observable
final class TransferModel {
enum Phase { case editing, submitting, failed(String), sent }
var amountText = ""
private(set) var phase: Phase = .editing
}- Failure mode: focus, validation, auth and navigation all in one app-wide store, so an unrelated update refreshes this form.
Follow-ups:
- The text field focus. Where does it live? (In the view, as
@FocusState. Nothing else reads it.) - The selected account must match on three screens and can change from a deep link. Where does it live now?
Weak answer: "I'd add a fourth flag for success." More flags, more impossible states.
2. "With @Observable, when does a view update?"
What is scored: exact dependency tracking, and how API shape defeats it.
A strong answer covers:
- Apple's docs: with Observation, SwiftUI updates a view only when an observable property changes and the view's
bodyreads it. WithObservableObject, any@Publishedchange updates the view, read or not. - Tracking follows what is read. A computed convenience property that touches five stored properties makes the view depend on all five.
- The fix is in the model's API: expose the narrow property the view needs, or a precomputed value.
- Evidence: update counts in Instruments before and after.
Follow-ups:
- A dashboard reads
store.summary, and live prices tick every second. What updates? - How do you keep a property out of tracking? (
@ObservationIgnored)
Weak answer: "Observation fixed over-rendering for us." It only helps when what the view reads is narrow.
3. "Which property wrapper do you use for a model, and why?"
What is scored: ownership in one sentence per wrapper.
A strong answer covers:
@Statewhen the view creates and owns the model.- A plain property when the view only receives and reads it.
@Bindablewhen the child needs bindings, for aTextFieldorToggle. A binding is a capability: it gives the child authority to change state, so hand it out only where that is intended.@Environment(Model.self)for a model read deep in the tree, injected with.environment(model).- Older code:
@StateObject,@ObservedObject,@EnvironmentObject.
@Observable
final class ProfileModel {
var name = ""
}
struct ProfileScreen: View {
@State private var model = ProfileModel()
var body: some View {
ProfileForm(model: model)
}
}
struct ProfileForm: View {
@Bindable var model: ProfileModel
var body: some View {
TextField("Name", text: $model.name)
}
}Follow-ups:
- A child only displays the name. Does it still get
@Bindable? - The child creates its own model with
@Stateinstead of receiving it. What goes wrong?
Weak answer: listing wrappers from memory with no owner for each.
4. "A teammate fixed index-based row ids by giving each row UUID(). What happens?"
What is scored: knowing that identity needs stability, and uniqueness alone does not give it.
A strong answer covers:
- Index identity breaks on insert, sort or filter: state attaches to the slot, so an in-progress edit can jump to another record.
- A fresh
UUID()created each time rows are built from new data breaks the other way: every reload looks like all-new rows, so row state is dropped,.taskwork restarts and the list animates as a full replacement. - The right id is the record's own stable id, such as the server id.
struct Transaction: Identifiable {
let id: String // server id, stable for the life of the record
let merchant: String
}
// ForEach(feed) now follows the record through inserts, sorts and reloads.- SwiftUI Under Load's rule: if you derive an id from anything the view knows, the id is already wrong.
Follow-ups:
- The backend sends no stable id. What do you do?
- When would you change
.id(...)on purpose? (For example, to reset a form after a successful submit, with a comment saying why.)
Weak answer: "UUIDs are unique, so it's safe." Uniqueness never collides and still destroys state on every reload.
5. "The user types 'coffee', then 'coffeeshop'. The slow first result arrives last and overwrites the new one. Fix it."
What is scored: telling concurrency safety from product correctness.
A strong answer covers:
- An actor stops data races. It does not stop a valid but stale result from replacing a fresh one. That needs a relevance rule.
- Stamp each request with a revision and reject superseded results.
- In the view,
.task(id: query)cancels and restarts the work when the query changes. Apple documents that SwiftUI cancels and restarts the task when theidvalue changes, and can cancel it after the view disappears.
actor SearchRepository {
private var revision: UInt64 = 0
private let fetch: @Sendable (String) async throws -> [String]
init(fetch: @escaping @Sendable (String) async throws -> [String]) {
self.fetch = fetch
}
func search(_ query: String) async throws -> [String] {
revision &+= 1
let mine = revision
let results = try await fetch(query)
try Task.checkCancellation()
guard mine == revision else { throw CancellationError() }
return results
}
}- Failure mode: "whatever callback returns last wins." That is the absence of a policy.
Follow-ups:
- Two views ask for the same query at once. Do you send two requests?
- One of them cancels. Does the shared request stop for the other?
- The feed is a live price stream. Which values may you drop?
Weak answer: "Add a debounce." It reduces requests and still lets a slow response win.
6. "How do you model navigation so a deep link can build the stack?"
What is scored: navigation as state with one owner.
A strong answer covers:
NavigationStack(iOS 16 and later) with a binding to a path: an array of values, orNavigationPathfor mixed types.navigationDestination(for:)maps a value type to a screen. Apple's docs name deep links and state restoration as reasons to use a path.- A router owns the path, so there is one place that decides what is on screen.
- On restore, ids in a saved path are checked against records that may no longer exist.
Follow-ups:
- The restored path points at a deleted item. What does the user see?
- On iPad with two windows, is the path per window or shared?
Weak answer: a boolean per destination in each view. Nothing outside the view can drive it, and the back button becomes unpredictable.
7. "The data changed, but the view did not update. Why?"
What is scored: knowing what Observation can see.
A strong answer covers:
- Observation tracks writes to observable properties the view read.
- A common cause: a mutable class held inside an array of values. Changing a field on that object does not write the array property, so nothing fires.
- The fix: make the data the UI reads value types, so a change is a new value assigned back.
- Keep the fix narrow. Reference types no view reads through, such as a network client or a logger, are fine.
Follow-ups:
- How would you write a test that catches this?
- The same model also feeds a UIKit screen. What changes?
Weak answer: "Call objectWillChange.send()." That is the older ObservableObject API and hides the model problem.
8. "Your app-wide store refreshes the whole screen on every price tick. What do you do?"
What is scored: matching store boundaries to truth boundaries.
A strong answer covers:
- Split the store by kind of truth: accounts, balances, feed. A balance tick then reaches only balance readers.
- Keep fast-changing values out of a shared environment object that many views read.
- Services the store uses (API client, analytics) are collaborators, marked
@ObservationIgnored, and injected. - Evidence: in Instruments, show that a change in one store no longer updates views reading another.
Follow-ups:
- One view needs data from three stores. Is that a problem?
- When is one store still the right call?
Weak answer: "Wrap the list in .drawingGroup()." A rendering fix for a dependency problem.
9. "You refactored a screen. How do you prove nothing reset?"
What is scored: testing behaviour that pixels cannot show.
A strong answer covers:
- State storage belongs to view identity. Moving a wrapper or changing structure can reset state with no visible change.
- Test focus, in-progress edits, navigation position and running tasks, not only screenshots. SwiftUI Under Load's line: the pixels are the one thing that does not reveal an identity regression.
- A deterministic test: start an edit on a seeded record, insert a new record at the top, assert the edit is still on the original record.
- Keep logic in the model, where plain unit tests are cheap.
Follow-ups:
- Which test would fail for both the index id and the fresh-UUID id?
- How do you test that a task was cancelled when the view went away?
Weak answer: "Snapshot tests passed." They prove the screen looks the same, and nothing else.
10. "What does @ObservationIgnored mean, and what does it not mean?"
What is scored: separating tracking from architecture.
A strong answer covers:
- It keeps a property out of view dependency tracking, which suits services and caches the view never displays.
- It says nothing about ownership, isolation or testability.
- An ignored dependency built inline inside the model is still untestable. Inject it through
init. - Observation removes boilerplate. It does not decide ownership, persistence or feature boundaries.
Follow-ups:
- An ignored property is later shown in the UI. What breaks?
- Half the app still uses
ObservableObject. How do the two meet at the boundary?
Weak answer: "It's for properties that don't matter." The repository behind the screen matters a lot; it just should not trigger redraws.
For where these state rules sit in the wider app, see iOS architecture interview questions. For a full self-check before the loop, use the iOS interview checklist. To pick a prep book for the rest of the loop, see the iOS interview prep book guide.
What changed in 2024 to 2026
- Swift 6 (17 September 2024) added an opt-in language mode that reports potential data races as compiler errors, which affects how results move from background work to UI models. (Announcing Swift 6)
- Swift 6.2 (15 September 2025) added an option to run code on the main actor by default, suggested in the post for UI code, and the
@concurrentattribute. (Swift 6.2 Released) - The
.taskmodifier gained anameparameter for a human-readable task name. Apple's docs say it has no effect before iOS 26.4. (Apple: task(id:name:priority:file:line:_:)) - Observation remains Apple's documented path for iOS 17 and later, and migration can be gradual: Apple's guide says an app can mix
ObservableandObservableObjecttypes. (Apple: Migrating to the Observable macro)
Say which OS floor your app supports before answering with iOS 17 APIs. Interviewers check.
How the rounds run
Formats vary by company and level. A SwiftUI round may be a talk-through, a small live build, or a review of existing code. Some loops have no SwiftUI questions at all. Ask the recruiter what each round scores, whether you will write code live, and which OS version the team targets.
If you build live and get stuck, say so out loud. I have never written no hire because a candidate stalled. I write it when they hide the stall, because from my chair silence and confusion look the same.
Sources
- Migrating from the Observable Object protocol to the Observable macro, developer.apple.com, accessed 21 October 2026
- NavigationStack, developer.apple.com, accessed 21 October 2026
- task(id:name:priority:file:line:_:), developer.apple.com, accessed 21 October 2026
- Announcing Swift 6, swift.org, 17 September 2024
- Swift 6.2 Released, swift.org, 15 September 2025