Skip to content
tezvyn:

iOS & Swift

SwiftUI, UIKit, Xcode, Swift language, Apple platforms

310 bites

Test yourself: Top 30 iOS & Swift interview questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Everything in iOS & Swift, page 7

Difference between .xcodeproj and .xcworkspace, and when to use a workspace
easy2 min read

Difference between .xcodeproj and .xcworkspace, and when to use a workspace

Tests your mental model of Xcode build containers. A project defines one buildable unit; a workspace groups multiple projects so they build together and share derived data. Use it for package managers or modular codebases.

advanced2 min read

How does Swift async/await improve on completion handlers?

Tests structured concurrency mastery over callback control flow. A strong answer covers inversion of control, suspension points as yield locations, and Tasks as parent-child units.

Explain Copy-on-Write in Swift and implement it for custom structs
advanced2 min read

Explain Copy-on-Write in Swift and implement it for custom structs

Tests value semantics with reference storage and uniqueness checks. A strong answer explains CoW delays copy until mutation via isKnownUniquelyReferenced, lists custom steps: wrap, read, check, clone. Red flag: assuming structs are automatically CoW.

intermediate2 min read

What is a closure capture list? Explain [weak self] versus [unowned self].

Define capture lists, contrast [weak self] safe optionality against [unowned self] crash risk, and match each to lifetime guarantees.

intermediate2 min read

What are Swift generics, why useful, and write a swap function?

This tests parametric polymorphism and type-safe reuse. A strong answer defines generics as placeholder types for reusable code, then writes a swap<T> function using inout parameters. Red flag: confusing generics with Any or omitting inout.

intermediate2 min read

What is a retain cycle in ARC with closures?

It tests reference counting and closure capture semantics. A retain cycle forms when a closure captures self strongly while self holds the closure; break it with weak if self can deallocate, or unowned if it will outlive the closure.

easy2 min read

Explain protocols and how extensions provide default implementations

Tests behavior sharing without inheritance. A strong answer defines protocols as requirements, shows extensions injecting default implementations, and contrasts this with base-class inheritance.

Swift struct vs class: differences and when to choose each
easy2 min read

Swift struct vs class: differences and when to choose each

Tests value vs reference semantics and let mutability. Strong answers contrast copy behavior with shared references, note allocation tendencies, and choose struct for value semantics or class for identity.

intermediate2 min read

Explain the primary differences between a struct and a class in Swift

Tests value versus reference semantics and their impact on memory and mutation. Strong answers note structs copy on assignment and lack inheritance, while classes share heap instances via ARC. Red flag: claiming structs are always stack-allocated.

easy2 min read

What is an optional in Swift? Demonstrate two safe unwrapping methods.

This checks Swift type safety and nil-handling. A strong answer defines Optional as an enum, demonstrates if let binding, and shows the nil-coalescing operator ?? for defaults. Avoid suggesting force-unwrapping with ! as a safe pattern.

easy2 min read

What is the difference between let and var in Swift?

This tests value semantics beyond syntax. A strong answer defines let as immutable and var as mutable, notes that let on a reference type only fixes the pointer, and cites clearer intent and compiler optimization.

intermediate2 min read

KVO: Swift's Built-In Observer Pattern

KVO lets an object subscribe to property changes on another object automatically. It shines when you need UI updates driven by model state, but forgetting to remove observers before deallocation crashes your app with an NSException.

intermediate2 min read

Thread Sanitizer catches data races in Swift

Thread Sanitizer turns flaky race crashes into reproducible reports by monitoring memory accesses at runtime. Use it in Xcode to catch unsynchronized cross-thread reads and writes. It only catches races that execute during your test run, so coverage matters.

intermediate2 min read

Profiling iOS Memory with Instruments

Instruments X-rays your heap to catch objects that outstay their welcome. Profile image-heavy features or when jetsam kills your app. Never trust Simulator memory numbers; always validate on physical hardware.

intermediate2 min read

@objc: Swift's Bridge to Objective-C

@objc is the bridge badge that exposes Swift code to the Objective-C runtime so UIKit selectors and KVO work. You need it for target-action and Core Data. Forget it and you get a runtime crash, not a compiler error.

intermediate2 min read

XCFrameworks: One Bundle for Every Apple Platform

An XCFramework is a shipping container for compiled Apple libraries: one bundle holds device, simulator, and Mac binaries so Xcode picks the right slice automatically. Use it to distribute closed-source SDKs.

intermediate2 min read

Dependency Resolution in iOS Package Managers

Dependency resolution finds one version of every library that satisfies all transitive requirements. It runs when SPM, CocoaPods, or Carthage builds your graph. The footgun is tight upper bounds; they multiply unresolvable diamond conflicts.

intermediate2 min read

XCTestCase: One Fresh Instance Per Test

A XCTestCase subclass is a lab bench for isolated experiments. Each test method is a fresh invocation checked by the runner. The silent killer is shared mutable state on the case: without setUp, tests flake because execution order is never guaranteed.

intermediate2 min read

MatchedGeometryEffect: Shared Element Hero Transitions

MatchedGeometryEffect lets two views share one spatial identity, so a thumbnail can appear to fly into a detail sheet across view hierarchies. It only works if both views exist simultaneously during a withAnimation block; otherwise the transition snaps.

intermediate2 min read

Custom Rendering with draw(_:)

draw(_:) is the callback where UIKit asks your view for pixels. Override it to render custom shapes or text with Core Graphics when stock views fall short. The footgun is calling it directly or doing non-drawing work inside; use setNeedsDisplay() instead.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles