All posts

Interview · UIKit · SwiftUI

UIKit and SwiftUI interview questions that actually come up

The questions iOS interviews actually ask, answered in a sentence or two, with the trap hidden in each one. No 400-question dump.

Muhammad Afham · July 2026 · 5 min read

UIKit

1 · Frame vs. bounds

Rotate a view and the bounds stay put while the frame grows to contain it. Trap: you move a view with frame or center. Changing bounds.origin scrolls its contents instead.

2 · UIViewController lifecycle

Trap: don't do frame-dependent work in viewDidLoad, because the view isn't sized for the real screen yet.

3 · Cell reuse

Lists recycle a small pool of cells, so a dequeued cell still holds the previous row's content and any in-flight image load. Reset it in prepareForReuse() by clearing the image and cancelling the download, or you get the wrong image flashing in the wrong row during fast scroll.

4 · Content hugging vs. compression resistance

In a tight row of two labels, the one with lower compression resistance truncates, and the one with lower hugging stretches.

5 · Retain cycles

A retain cycle is two objects strongly referencing each other, so ARC never frees them. In UIKit they hide in two places:

Then weak vs unowned:

6 · When to still choose UIKit in 2026

Reach for UIKit when you need control the declarative layer doesn't cleanly expose:

Reach for SwiftUI for most new screens and cross-platform work. It's rarely all or nothing, since real apps embed one inside the other.

SwiftUI

7 · @State / @Binding / @StateObject / @ObservedObject

It comes down to ownership:

Trap: use @ObservedObject where you needed @StateObject and a parent re-render silently resets the object's state.

8 · @Observable vs. ObservableObject

Since iOS 17 the @Observable macro replaces ObservableObject plus @Published. Two wins to name:

Own the model with @State, and make bindings with @Bindable.

9 · @EnvironmentObject vs. @Environment

Trap: a missing @EnvironmentObject is a runtime crash, not a compile error.

10 · Why views are structs

A view is a cheap, disposable description of UI that SwiftUI recreates constantly. Value types make that churn fast and rule out shared-mutable-state bugs. State that must persist lives outside the struct, in the storage @State manages.

11 · What triggers a redraw

SwiftUI re-runs body, diffs the new view tree against the old, and updates only what changed. That needs identity, of two kinds:

12 · NavigationStack vs. NavigationView

NavigationView is deprecated. NavigationStack (iOS 16+) is data-driven: you bind it to a path array, so navigation becomes state you can push, pop to root, or restore a deep link by assigning to it.

13 · Mixing UIKit and SwiftUI

Follow-up: data flows down through updateUIView and back up through a Coordinator writing to a @Binding.

Fundamentals both tracks test

14 · Struct vs. class

Default to structs. Trap: let on a class freezes the reference, not the object, so you can still mutate its var properties.

15 · ARC, weak vs. unowned

Compile-time reference counting frees a class instance when its strong count hits zero. Value types don't need it. The two non-strong references:

16 · async/await vs. GCD, and actors

Follow-up: GCD isn't dead. async/await is built on it, and you'll still maintain DispatchQueue code.

What each question is really testing

When they askThey're really checking
Frame vs. boundsDo you understand coordinate systems, or memorise a sentence
Cell reuseHave you shipped a real list and hit the stale-content bug
State vs. StateObjectDo you understand ownership and lifetime
@ObservableAre you current with iOS 17+, or writing 2021 SwiftUI
What triggers a redrawDo you grasp identity and diffing
Struct vs. classDo you have judgement about when each fits

For every one, don't stop at the definition. Say what it's for, name what breaks without it, and volunteer the follow-up. That's the difference between reading a list like this and having shipped.

Interviewing for a senior iOS role?

I run mock interviews and prep, covering these questions plus system design and the behavioural round. First session is free.

Book a free 1:1 Connect on LinkedIn