Top 30 Intermediate iOS & Swift Concepts Quiz
30 intermediate multiple-choice iOS & Swift concept questions, the mechanics underneath the basics: how the pieces relate and where the usual mental model stops holding. They come from 30 bites in the iOS & Swift library, the middle slice of the 180 iOS & Swift concept questions in the library. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.
SwiftUI, UIKit, Xcode, Swift language, Apple platforms
30 questions. Pick an answer, or open “Show the answer” to read it.
Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.
Question 1 of 30
What is the fundamental mechanism by which Swift Optionals prevent runtime crashes from missing values?
Show the answer
Answer: d · They require explicit checks for nil values at compile time, making absence part of the type.
The card states Optionals make "the potential absence of a value an explicit part of its type system, forcing developers to handle the 'nil' case at compile time." This explicit handling prevents runtime crashes by ensuring nil is addressed before code execution. Force-unwrapping (option C) is explicitly mentioned as an anti-pattern that causes crashes if the value is nil, not prevents them.
Read the full bite: Swift Optionals: Handling Nothing Safely
Question 2 of 30
When should a developer generally prefer using a Swift struct over a class for a new data type?
Show the answer
Answer: b · When the data is simple, self-contained, and changes to a copy should not affect the original.
Structs are value types, meaning they are copied on assignment, and changes to the copy do not affect the original. This makes them suitable for simple, self-contained data where independent copies are desired. Classes are used for shared identity and inheritance, and are managed by ARC.
Read the full bite: Swift Structs vs. Classes: Value vs. Reference Types
Question 3 of 30
You add a new case to a widely-used enum. When does this silently undermine compile-time safety?
Show the answer
Answer: b · When switches over the enum include a default clause
A default clause catches the new case automatically, so the compiler cannot force you to handle it explicitly. Omitting a default clause produces a build error for unhandled cases, which preserves compile-time safety.
Question 4 of 30
Which scenario best justifies using Swift's explicit error handling system (with "throws" and "do-catch")?
Show the answer
Answer: d · For operations that can fail in various ways, requiring the caller to understand the specific type of failure to recover.
The card states Swift's error handling is for "recoverable errors where the caller needs context about what went wrong." Option D directly reflects this, emphasizing the need for specific failure context. Option A is incorrect because the card advises using optionals for simple binary success/failure without extra context.
Read the full bite: Swift Error Handling: Throwing, Catching, and Propagating
Question 5 of 30
In Swift, when is using a capture list with `self` most critical to prevent a retain cycle?
Show the answer
Answer: b · When a closure is stored as a property of a class instance and references `self`.
Option B correctly identifies the scenario where a retain cycle is most likely: when a closure is stored as a property of a class instance and captures `self`. This creates a strong reference from the instance to the closure and from the closure back to the instance. Option A describes a closure that is executed immediately, which does not typically lead to a retain cycle because the closure does not outlive the function call.
Read the full bite: Retain Cycles and Capture Lists in Swift
Question 6 of 30
Two threads hold references to the same Swift array through two variables, a and b, and both threads call a mutating method on their variable at the same time without any lock. What is the risk?
Show the answer
Answer: c · The isKnownUniquelyReferenced check itself is not thread-safe, so concurrent mutation can race and corrupt the shared buffer
Copy-on-write's uniqueness check and buffer swap are not synchronized, so two threads racing through them concurrently can corrupt shared state or crash. Arrays are not automatically thread-safe, there is no internal lock making one mutation block for the other, and this is a runtime hazard the compiler cannot catch.
Question 7 of 30
What is the primary reason to use an associated type within a Swift protocol?
Show the answer
Answer: b · To enable the protocol to refer to a type whose concrete definition is only known by conforming types.
Associated types exist to allow a protocol's blueprint to refer to a type that is not known until a concrete type adopts the protocol, making the protocol generic over types it uses. Option C is a tempting distractor because, while desirable, the card explicitly states that protocols with associated types cannot be used directly as concrete types for variables or collections without workarounds.
Read the full bite: Associated Types: Making Protocols Generic
Question 8 of 30
What is the primary advantage of using a key path over direct dot notation for property access?
Show the answer
Answer: d · It allows for dynamic, type-safe referencing of properties in generic contexts.
Key paths are designed to pass a type-safe reference to a property itself, enabling generic APIs and dynamic access without losing compile-time safety. Direct dot notation is generally more performant for simple, known property access, making option B incorrect. Key paths enforce type safety, disproving option C, and they refer to the property's location, not its value, making option A incorrect.
Read the full bite: Key-Path Expressions: Type-Safe Pointers to Properties
Question 9 of 30
What is the primary advantage of using an opaque type (e.g., some Collection) as a function's return type?
Show the answer
Answer: b · It provides flexibility to change the underlying implementation without breaking client code.
Opaque types hide the concrete return type behind a protocol, allowing the API provider to change the underlying implementation (e.g., from one collection type to another) without affecting client code that only depends on the protocol. Option A is incorrect because a function with an opaque return type must always return the exact same concrete type. Option D is incorrect because the 'opaque' nature means the client only sees the protocol's capabilities, not the concrete type's unique methods.
Read the full bite: Opaque Types: Hide Implementation, Not Capabilities
Question 10 of 30
To manage distinct API endpoints for development, staging, and production environments in an Xcode project, what is the recommended approach?
Show the answer
Answer: c · Define custom Build Configurations for staging and production, then create Schemes that specify which configuration to use for each environment's actions.
Custom Build Configurations are designed for managing environment-specific details like API endpoints, and Schemes then link these configurations to specific actions. The card explicitly warns against putting environment settings directly into a Scheme, as that is a common pitfall.
Question 11 of 30
Which statement best describes the fundamental mental model of Auto Layout?
Show the answer
Answer: d · Declaring how UI elements relate to each other through a system of constraints.
Auto Layout's core mental model is about describing relationships between views (e.g., '8 points below the logo') rather than setting fixed frames. Option C describes the manual frame calculation that Auto Layout replaced, making it a tempting but incorrect distractor.
Read the full bite: Auto Layout: Describing Relationships, Not Frames
Question 12 of 30
Under which scenario would using a breakpoint likely be counterproductive for debugging?
Show the answer
Answer: b · Diagnosing a race condition that is highly sensitive to execution timing.
The card states that breakpoints should be avoided for 'issues that are highly timing-dependent, like race conditions,' because pausing the program can alter its behavior and make the bug disappear. The other options describe ideal use cases for breakpoints, such as inspecting variable states or understanding code flow.
Question 13 of 30
Which UI issue is the Xcode View Debugger uniquely suited to diagnose?
Show the answer
Answer: d · A button failing to respond to taps because an invisible view is covering it.
The View Debugger is designed to reveal the visual hierarchy, including invisible views that might be intercepting touches, as highlighted in the canonical example. It is not for debugging application logic (like incorrect text or network issues) or dynamic animations.
Read the full bite: Xcode View Debugger: Uncover Hidden UI Bugs
Question 14 of 30
What is a key advantage of Swift Package Manager compared to previous dependency management tools?
Show the answer
Answer: c · It is a first-party, deeply integrated solution within Xcode.
The card states that Apple created SPM to be a "first-party, officially supported, and deeply integrated way to handle dependencies." The other options describe limitations or common misconceptions, as SPM may not support complex pre-build scripting, can still have version conflicts, and might not work with older, unmaintained libraries.
Read the full bite: Swift Package Manager: Native Dependency Management
Question 15 of 30
What is the primary technical advantage of UITableView's cell reuse mechanism?
Show the answer
Answer: d · It significantly reduces memory usage and improves scrolling fluidity by avoiding constant view creation.
The card emphasizes that cell reuse prevents a "memory nightmare" and is "far cheaper than creating a new view from scratch," directly addressing memory efficiency and performance. While other options might describe aspects of table view usage, they are not the core technical benefit of the reuse mechanism itself.
Question 16 of 30
What is the primary reason to choose UICollectionView over UITableView for displaying data?
Show the answer
Answer: b · To enable complex, non-linear layouts like grids, stacks, or custom arrangements.
The card emphasizes UICollectionView's purpose is to manage and display data in "highly complex, non-linear, and dynamic arrangements" such as grids or stacks, which UITableView cannot easily achieve. While both are efficient and handle interactions, only UICollectionView offers this advanced layout flexibility as its primary distinguishing feature.
Read the full bite: UICollectionView: Grids, Stacks, and Custom Layouts
Question 17 of 30
A parent view manages a boolean state and allows a child view to directly modify it. How should these properties be declared?
Show the answer
Answer: a · Parent: @State, Child: @Binding
The parent view owns the data, making @State the correct choice for its private source of truth. The child view needs to modify the parent's data without owning it, which is the purpose of @Binding. Option B is incorrect because @State in the child would create a separate, owned copy, not modify the parent's original value.
Read the full bite: SwiftUI State and Binding: Owning vs. Sharing Data
Question 18 of 30
According to the "Russian nesting dolls" mental model, why does the order of SwiftUI modifiers significantly impact a view's appearance?
Show the answer
Answer: a · Each modifier creates a new, wrapped view, and subsequent modifiers operate on the result of the previous modification.
Option A accurately describes the mental model: each modifier returns a new view that wraps the previous one, so the order determines which 'doll' (or modified view) the next modifier acts upon. Option B is incorrect because modifiers are non-destructive and do not alter the original view; they return a new one.
Read the full bite: SwiftUI Modifiers: Stacking Changes on Views
Question 19 of 30
Which action explicitly leads to broken scrolling behavior when using a SwiftUI List?
Show the answer
Answer: b · Nesting the List within a parent ScrollView.
The card explicitly warns that nesting a List inside another scrolling view like a ScrollView is a "footgun" that "breaks scrolling behavior." Other options describe inefficient uses or prerequisites, not actions that break the List's scrolling.
Read the full bite: SwiftUI List: More Than Just a Table View
Question 20 of 30
What is the primary role of UIHostingController in iOS development?
Show the answer
Answer: a · To enable the integration of SwiftUI views within an existing UIKit-based application.
UIHostingController is designed to bridge SwiftUI content into UIKit apps, allowing for incremental adoption of SwiftUI. It does not convert UIKit views, nor is it used for embedding UIKit in pure SwiftUI, and it can introduce performance overhead rather than optimize rendering.
Read the full bite: UIHostingController: Bridge SwiftUI into UIKit Apps
Question 21 of 30
In iOS 13 and later, what is the fundamental role of UISceneDelegate in an application's architecture?
Show the answer
Answer: a · To handle the lifecycle and state changes for a single UI instance, such as a window or scene.
The card states UISceneDelegate is the "lifecycle manager for a single window of your app's UI" and was created "to manage a single UI instance." Option D describes the role of AppDelegate for the overall app process, not UISceneDelegate.
Read the full bite: UISceneDelegate: Managing Your App's UI Instances
Question 22 of 30
What is the primary advantage of implementing the MVVM pattern in a complex SwiftUI view?
Show the answer
Answer: c · It makes the view's business logic independently testable and keeps the view focused solely on UI presentation.
MVVM's core benefit is separating business logic from the UI, making the logic independently testable and simplifying the view's role to just rendering. While MVVM moves much of the state, purely presentational UI state can still reside in the view, so it doesn't eliminate all @State.
Read the full bite: MVVM: Separate SwiftUI Logic from Layout
Question 23 of 30
What is the main benefit of using Dependency Injection in Swift applications?
Show the answer
Answer: b · It allows objects to be tested independently by providing flexible ways to swap out their external dependencies.
The card explicitly states that Dependency Injection exists to break up tightly coupled code, making objects testable in isolation by allowing mock dependencies to be injected. Option B directly reflects this core purpose. Option D is a tempting distractor, but the card notes that simple initializer injection can actually complicate dependency passing in deep SwiftUI hierarchies, not simplify it.
Read the full bite: Dependency Injection in Swift: Stop Creating, Start Receiving
Question 24 of 30
Which scenario represents an inappropriate use of an iOS background mode?
Show the answer
Answer: d · Regularly fetching new content for a social media feed to keep it updated.
Background modes are for specific, user-initiated tasks like audio or location. Regularly fetching content is a general-purpose task explicitly stated as inappropriate, better handled by the BackgroundTasks framework.
Read the full bite: iOS Background Modes: A Hall Pass for Your App
Question 25 of 30
Which scenario best justifies the use of the Singleton design pattern?
Show the answer
Answer: b · A global analytics tracker that sends usage data to a server from various parts of the application.
A global analytics tracker is a classic example of a shared, singular resource that needs to coordinate actions across the system, fitting the Singleton's purpose. The card warns against using Singletons for complex, mutable state like a shopping cart (Option C) due to testing difficulties and tight coupling.
Read the full bite: The Singleton Pattern: One Instance to Rule Them All
Question 26 of 30
Which approach best describes how NavigationStack programmatically manages its view hierarchy?
Show the answer
Answer: a · It binds to an array of hashable data, where changes to the array reflect the navigation path.
NavigationStack is data-driven, using a binding to an array (the 'path') to represent the navigation stack. Modifying this array directly controls the views on screen, unlike imperative global managers or direct view tree manipulation.
Read the full bite: NavigationStack: Programmatic Navigation in SwiftUI
Question 27 of 30
Which navigation scenario is the primary intended use case for SwiftUI's NavigationLink?
Show the answer
Answer: d · Navigating from a list item to its corresponding detailed information view.
NavigationLink is designed for hierarchical 'push' navigation, such as a master-detail flow where tapping a list item reveals its details. It is explicitly stated not to be used for tab-based navigation (like option C) or modal presentations like full-screen covers (option A) or popovers (option B).
Read the full bite: NavigationLink: Pushing Views in SwiftUI
Question 28 of 30
When should you prefer NavigationSplitView over NavigationStack for an application's primary interface?
Show the answer
Answer: c · For applications that require a multi-column layout to display hierarchical data adaptively across different screen sizes.
NavigationSplitView is designed for adaptive multi-column layouts that present hierarchical data, automatically adjusting to screen size. In contrast, NavigationStack is suitable for simple, linear flows or single-column hierarchies, making option D incorrect.
Read the full bite: NavigationSplitView: Adaptive Layouts for All Screen Sizes
Question 29 of 30
What is the primary purpose of Keychain Services in an application?
Show the answer
Answer: a · To securely persist small, sensitive data like user credentials
Keychain Services is designed for securely storing small, sensitive data like passwords and tokens, not for large amounts of data or as a general-purpose database. The operating system, not the app, manages the encryption keys.
Read the full bite: Keychain Services: A Secure Vault for Small Secrets
Question 30 of 30
What is Core Data's primary role in an application's architecture?
Show the answer
Answer: d · Managing a complex, interconnected graph of in-memory model objects.
Core Data is fundamentally an object graph manager, designed to manage a network of interconnected in-memory model objects and their lifecycle. While it can persist data, its core strength isn't direct SQL access, simple key-value storage, or cross-platform database sharing, which are explicitly mentioned as scenarios where it's not ideal.
Read the full bite: Core Data: An Object Graph, Not Just a Database
Could you explain these out loud?
That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.