In short
- A mock round works best when it starts from 1 small piece of behaviour you can make correct and test.
- Main-actor isolation protects state access. It does not tell you whether a late response is still relevant.
- Cancelling work and deciding whether a result may reach the screen are 2 separate checks.
- Change 1 requirement after the first solution and say what stays valid, what must change and what you check first.
- End with 1 repair target small enough to repeat tomorrow.
You cancel the old search request. The new results appear. Then the old request finishes and replaces them.
“But I cancelled it” explains the intention. You still need to explain the screen.
That is where I would start a senior iOS mock interview with a small piece of behaviour that the candidate has to make correct. There is room to discuss Swift concurrency, ownership, testing and UI state without turning the session into a tour of framework names.
This practice round takes 60 minutes, including a short debrief. You can run it with a colleague or record yourself. Real loops often assess these areas in separate rounds, so this condensed session helps you find which area needs a longer practice session.
You will leave with code, an explanation of 1 changed requirement and a specific repair target.
Set up the round before you see the answers
Use a Swift project or package that already builds. Confirm the Swift language mode and concurrency settings. Setup problems should not consume the practice session unless using an unfamiliar editor is the skill you intend to practise.
If a colleague is interviewing you, ask them to read the candidate prompts aloud and keep the follow-ups hidden until the scheduled time. If you are practising alone, copy the prompts into a separate note first. Record your screen and voice, then attempt each block before reading its discussion.
For this attempt, work without looking anything up. Afterwards, use documentation to check uncertain claims. If your real interview allows reference material, run a second session under those exact rules.
| Time | Work | Evidence to keep |
|---|---|---|
| 0 to 5 minutes | Clarify the search feature | Assumptions and behaviour contract |
| 5 to 12 minutes | Explain the concurrency risk | An ordered sequence of events |
| 12 to 32 minutes | Implement a small search model | Running code and at least 1 meaningful check |
| 32 to 42 minutes | Diagnose SwiftUI identity | Explanation and a focused correction |
| 42 to 52 minutes | Adapt the design for offline use | A data-flow sketch and revised contract |
| 52 to 60 minutes | Debrief | 1 supported strength and 1 repair target |
Minutes 0 to 5, clarify what the user should see
Candidate prompt
Build the model behind a search screen. The user types a query, the app calls a search service, and the screen shows matching products. Requests can finish in any order.
Before discussing actors or architecture, define the visible behaviour.
Useful questions include whether an empty query clears the screen, whether previous results remain visible while loading, whether matching ignores surrounding whitespace, and what should happen when a refresh fails.
For this exercise, use these answers.
- An empty or whitespace-only query clears results and makes no request.
- A changed query clears previous results while its request is pending.
- Only the latest query may publish results or an error.
- Cancellation should not appear as a user-facing failure.
- Persistence and pagination are outside the initial implementation.
Write the central rule in 1 sentence. A result may update the screen only if it still belongs to the current search intent.
This gives you something testable. “Use MVVM” does not yet say what should happen.
Minutes 5 to 12, explain why isolation alone is insufficient
Candidate prompt
The search model is isolated to
MainActor. Can an older request still overwrite newer results?
Yes. Main-actor isolation protects access to the model's isolated state. It does not establish which request is still relevant after an asynchronous suspension.
Explain a possible execution in order.
- The user searches for
cameraand request A starts. - The user searches for
camera bagand request B starts. - B returns and publishes the correct results.
- A returns later and publishes obsolete results.
No simultaneous mutation is required for that failure. The state changes happen at different times, in the wrong logical order. The Swift language guide describes each await as a possible suspension point that gives other concurrent code an opportunity to run, so anything you assumed before an await needs checking after it.[1]
Interviewer follow-up
What if we cancel A as soon as B starts?
Cancellation is useful for stopping unnecessary work, but the state publication rule still deserves an explicit defence. Identify the request or revision associated with the current intent and check it before publishing. Also respect the task's cancellation state.
An acceptable explanation sounds like this.
“I will cancel work when it becomes unnecessary. Before assigning the result, I will also check that this operation is still current. Those checks answer different questions. Should this work continue, and may this result affect the screen?”
The exact implementation can vary. The explanation must account for the late response.
Minutes 12 to 32, implement and test the smallest useful model
Candidate prompt
Implement the search behaviour we agreed on. Inject the service so you can control response order in a test. You may omit the UI.
Start with the model's observable facts, which are results, loading and an optional error. Give 1 owner responsibility for the current intent. Use a service boundary small enough to replace with a fake.
A practical sequence is to make 1 successful query work, add the empty-query behaviour, then protect publication against obsolete responses. If you add debouncing, keep it separate from the correctness rule, because waiting before starting a request does not prove that its eventual response is current.
Do not spend half the time constructing a generic networking layer. The service is already a boundary in this exercise. What needs demonstrating is correct behaviour when that service returns in an inconvenient order.
20 minutes is realistic for a candidate who has built this shape before and prepared for it. On a first attempt it often is not. If time runs short, cut in this order. Drop the empty-query branch, then the error path, and keep the late-success check, because it is the one that fails without the guard.
A reference model
This is 1 way to meet the contract. Every text change, including clearing the field, increments the current intent. A result is published only when its intent is still current and its task has not been cancelled. The task property is readable so a check can await it instead of guessing how long to wait.
import Foundation
protocol SearchService: Sendable {
func search(_ query: String) async throws -> [String]
}
struct SearchFailure: Error, Equatable {}
@MainActor
final class SearchModel {
private(set) var results: [String] = []
private(set) var isLoading = false
private(set) var errorMessage: String?
/// The current request. Visible so a check can await it.
private(set) var task: Task<Void, Never>?
private let service: any SearchService
private var currentIntent = 0
init(service: any SearchService) {
self.service = service
}
/// Every text change is a new intent, including clearing the field.
func queryChanged(_ text: String) {
task?.cancel()
currentIntent += 1
let intent = currentIntent
results = []
errorMessage = nil
let query = text.trimmingCharacters(in: .whitespacesAndNewlines)
guard !query.isEmpty else {
isLoading = false
task = nil
return
}
isLoading = true
task = Task {
do {
let found = try await service.search(query)
finish(intent: intent, results: found, error: nil)
} catch is CancellationError {
// Stopping work is not a user-facing failure.
} catch {
finish(intent: intent, results: [], error: "Search failed")
}
}
}
private func finish(intent: Int, results: [String], error: String?) {
guard intent == currentIntent, !Task.isCancelled else { return }
self.results = results
self.errorMessage = error
isLoading = false
}
}The test that earns its place
Create a fake service whose requests you can complete manually. Avoid using arbitrary sleeps or a guessed number of yield calls to hope that responses arrive in the desired order. This fake also ignores cancellation on purpose, so a cancelled request can still return late, as a real one sometimes does.
actor ControlledService: SearchService {
private var pending: [String: CheckedContinuation<[String], Error>] = [:]
func search(_ query: String) async throws -> [String] {
try await withCheckedThrowingContinuation { pending[query] = $0 }
}
func hasPending(_ query: String) -> Bool { pending[query] != nil }
func complete(_ query: String, with results: [String]) {
pending.removeValue(forKey: query)?.resume(returning: results)
}
func fail(_ query: String) {
pending.removeValue(forKey: query)?.resume(throwing: SearchFailure())
}
}The sequence to control looks like this.
| Step | Controlled action | Expected screen state |
|---|---|---|
| 1 | Start A for camera | Loading, no results |
| 2 | Start B for camera bag | Loading, no results |
| 3 | Complete B with bag | Results contain bag |
| 4 | Complete A with camera | Results still contain bag |
The check below covers exactly this sequence. It awaits the model's own tasks, so there is no sleep. The only polling is started, which waits for a condition, the fake having recorded the request, not for a delay.
Then try the less obvious variant yourself, where B succeeds and A fails afterwards. An obsolete error must not replace the successful screen either, and the fake already has a fail(_:) method for it. The cleared query from the next follow-up and the whitespace-only query make good further checks.
func started(_ service: ControlledService, _ query: String) async {
while !(await service.hasPending(query)) { await Task.yield() }
}
@MainActor
func lateSuccessIsIgnored() async -> Bool {
let service = ControlledService()
let model = SearchModel(service: service)
model.queryChanged("camera")
let a = model.task!
await started(service, "camera")
model.queryChanged("camera bag")
let b = model.task!
await started(service, "camera bag")
await service.complete("camera bag", with: ["bag"])
await b.value
await service.complete("camera", with: ["camera"])
await a.value
return model.results == ["bag"]
}
let passed = await lateSuccessIsIgnored()
print(passed ? "PASS" : "FAIL", "late success does not replace newer results")
exit(passed ? 0 : 1)Put the 3 blocks in 1 main.swift file, in this order, and run swiftc -swift-version 6 main.swift -o checks && ./checks. It prints PASS. Now delete the guard line in finish and run it again. It prints FAIL and exits with status 1, which is what you want from a test that earns its place.
Interviewer follow-up
The user clears the text while a request is running. What can that request still change?
Treat clearing the query as a new intent. It invalidates the old operation even though it starts no replacement network request. Otherwise, the old response can refill a screen the user deliberately cleared.
If time runs out, leave a precise account of what works and what remains unverified. A compiling implementation with 1 controlled race check is more useful evidence than a larger implementation whose behaviour you have not checked.
If you want a rubric-scored version of this loop with a retry after a changed constraint, that is what Guided Practice in iOS Interview Training is for. For the underlying language discussion, see Swift concurrency interview questions.
Minutes 32 to 42, diagnose identity before replacing state management
Candidate prompt
A SwiftUI list contains editable rows. Each row has local state. After a refresh, edits reset even though the products appear unchanged. What would you inspect?
Ask how rows are identified. A computed id that returns a new UUID() on each access is 1 possible defect. Recreating model objects with newly assigned IDs on every response is another. Also inspect conditional branches and explicit .id(...) modifiers around the list.
Apple's explanation of SwiftUI connects identity to the lifetime of persistent view state.[2] Re-evaluating body alone does not prove that state should reset. You need to establish whether the conceptual row retained its identity.
Interviewer follow-up
The IDs are stable now. A user edits a product, leaves the screen and returns. Must the draft survive?
That is a product requirement. If the answer is yes, row-local state may have the wrong lifetime even with correct IDs. Move the draft to an owner that survives the required navigation, or persist it when durability is required. Say who clears it and when.
The correction should follow the requirement. Introducing an app-wide singleton because 1 draft disappeared would create a much larger ownership decision than the prompt justifies.
Minutes 42 to 52, change the data contract
Candidate prompt
The screen must now show saved search results immediately when the device is offline. What changes?
First clarify whether cached results must match the exact query, how stale results should be labelled, and whether the feature is read-only. This exercise adds offline reads, not offline ordering or payments.
A workable design reads saved results from a repository, starts a refresh when appropriate, and updates stored data after a successful response. The UI can distinguish initial loading, cached content and a refresh failure without collapsing them into a single error screen.
Keep the latest-intent rule. A repository change does not remove the risk of results from an older query reaching the current screen. In the reference model, the repository call would sit behind the same intent check.
Interviewer follow-up
Cached content is visible. The refresh fails. Do you clear the list?
With the agreed offline requirement, retaining useful content and showing a refresh failure is a defensible choice. Name the consequence, which is that the user can act on stale information. If availability or price matters, explain how the product communicates that limitation.
Minutes 52 to 60, score evidence, then choose 1 repair
Use this practice rubric.
| Dimension | Evidence to look for |
|---|---|
| Clarification | Defined empty, loading, success and failure behaviour |
| Concurrency | Explained the obsolete-response sequence accurately |
| Implementation | Produced a small solution matching the contract |
| Verification | Controlled response order and checked the final state |
| Ownership | Connected state to the required screen and draft lifetimes |
| Adaptation | Changed the relevant part of the design when offline reads were added |
For each dimension, mark demonstrated, demonstrated after a prompt, needs repair, or not reached. Attach a timestamp, test result or code location. Do not turn “not reached” into a technical failure, and do not add these labels into an invented readiness percentage.
A useful repair target reads like this. “I protected successful results but forgot obsolete errors. I will add the late-failure test and repeat that block tomorrow.”
“Study concurrency” is too broad to guide the next attempt.
Continue with structured practice
If this round exposed a gap you want to work through systematically, iOS Interview Training is $99, paid once. You keep the book and companion code, and you get 90 days of Guided Practice, with realistic prompts, a revision of your answer, changed constraints and a side-by-side comparison of your attempts. It includes 12 simulations scored on 6 dimensions. It is not a live mock interview with a person and not an AI interviewer. You can read the free sample before buying.
Keep today's attempt. On the next run, use a different query sequence and explain the correction without reading it. The improvement you want is visible in the answer you can now produce.
If you have a date for the loop, the 14-day senior mobile interview prep plan shows where a round like this fits. To see why the follow-up is where the round is decided, read the follow-up decides the senior mobile interview.
Sources
Questions readers ask
© 2026 Mike Salari, Interview Runtime. All rights reserved. Quoting a short excerpt with a link to this page is welcome; republishing the article, in full or in part, is not.



