Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

8668 bites

Page 151

How do you persist a custom Swift struct to JSON in Documents?
iOS & Swift2 min read

How do you persist a custom Swift struct to JSON in Documents?

Tests fluency with Codable and FileManager sandbox APIs. Good answer: conform to Codable, encode with JSONEncoder, resolve Documents directory via FileManager URLs, write Data atomically, and reverse with JSONDecoder.

When is UserDefaults right, what are its limits, and native types?
iOS & Swift2 min read

When is UserDefaults right, what are its limits, and native types?

Tests if you treat UserDefaults as a small preference store, not a database. Good answers name native plist types, cite no encryption and small size limits, and name Core Data or Keychain for heavy or sensitive data. Red flag: storing images or passwords.

Design state-driven navigation for a conditional wizard in UIKit and SwiftUI
iOS & Swift2 min read

Design state-driven navigation for a conditional wizard in UIKit and SwiftUI

This tests separating navigation state from UI. Model the flow as a state machine enum, derive the stack from state, and unit test transitions in plain Swift. A red flag is imperative pushes inside views or view controllers.

How would you architect the app root for onboarding vs authenticated flows?
iOS & Swift2 min read

How would you architect the app root for onboarding vs authenticated flows?

Tests window root swapping and state-driven architecture. Use a coordinator to own the window, swap rootViewController between nav and tab controllers on auth changes, and crossfade. Red flag: onboarding modal over tabs or keeping both hierarchies alive.

What NavigationView limitations did NavigationStack solve for programmatic navigation?
iOS & Swift2 min read

What NavigationView limitations did NavigationStack solve for programmatic navigation?

This tests why NavigationView programmatic navigation was brittle. A strong answer contrasts scattered NavigationLink isActive booleans and broken multi-destination stacks against NavigationStack's unified path array. A red flag is calling it a simple rename.

How do you pop to root in SwiftUI NavigationStack?
iOS & Swift2 min read

How do you pop to root in SwiftUI NavigationStack?

This tests declarative state-driven navigation. A strong answer binds NavigationStack to a NavigationPath, passes the binding down, and clears the path to pop to root. A red flag is suggesting UIKit popToRootViewController or legacy isActive hacks.

Handle a deep link URL in SceneDelegate and navigate to order detail.
iOS & Swift2 min read

Handle a deep link URL in SceneDelegate and navigate to order detail.

Handles willConnectTo and openURLContexts; parses path with URLComponents; validates ID; pushes detail onto nav stack.

Pass data back from a modally presented view controller delegate versus closure
iOS & Swift2 min read

Pass data back from a modally presented view controller delegate versus closure

This tests decoupled UIKit communication and memory safety. A strong answer outlines a weak delegate protocol and a closure with weak self, contrasting coupling and retain cycles. Red flag: singletons or direct parent references.

Explain the Coordinator pattern and the navigation problem it solves in MVC
iOS & Swift2 min read

Explain the Coordinator pattern and the navigation problem it solves in MVC

This tests if you see view controllers bloat from absorbing navigation flow. A good answer names 3 problems (delegate bloat, massive view controllers, embedded routing) and says coordinators own creation and routing.

Implement SwiftUI navigation between list and detail with product ID
iOS & Swift2 min read

Implement SwiftUI navigation between list and detail with product ID

Tests modern SwiftUI navigation and clean data flow. Great answer: NavigationStack with NavigationLink(value:) and navigationDestination(for:), plus a bound path for programmatic control.

Outline the key steps and APIs for State Preservation and Restoration
iOS & Swift2 min read

Outline the key steps and APIs for State Preservation and Restoration

Tests UIKit's automatic state restoration pipeline. Strong answers cover: opting in via AppDelegate, setting restorationIdentifiers, implementing encode/decodeRestorableStateWithCoder, and the system snapshot cycle.

How does the Coordinator pattern decouple navigation, and what are its components?
iOS & Swift2 min read

How does the Coordinator pattern decouple navigation, and what are its components?

This tests iOS separation of concerns. Explain that Coordinators extract navigation logic from view controllers for reuse, and describe AppCoordinator tree with child coordinators. A red flag is treating it as a router or ignoring parent-child retention.

How do you complete a file download after the app backgrounds?
iOS & Swift2 min read

How do you complete a file download after the app backgrounds?

This tests iOS background execution and URLSession background transfers. Configure a background URLSession, handle AppDelegate events, and respect the 30-second completion handler limit. Never claim NSTimer or beginBackgroundTask sustains background downloads.

iOS & Swift2 min read

Explain MVVM, its improvements over MVC, and Swift data binding techniques.

Tests architectural separation of concerns and pattern comparison skills. Define ViewModel as state transformer, cite MVC's massive view controller, and list Combine or closures for binding. Red flag: calling MVVM as MVC with no testability.

How do AppDelegate and SceneDelegate responsibilities differ?
iOS & Swift2 min read

How do AppDelegate and SceneDelegate responsibilities differ?

AppDelegate owns process events (launch, push); SceneDelegate owns per-window lifecycle and UI.

Integrate SwiftUI into UIKit and wrap UIKit for SwiftUI
iOS & Swift2 min read

Integrate SwiftUI into UIKit and wrap UIKit for SwiftUI

Tests bridging architecture between UIKit and SwiftUI using UIHostingController and UIViewRepresentable. A strong answer names hosting controllers for SwiftUI in UIKit, representable protocols for UIKit in SwiftUI, and lifecycle hooks.

Differences between @State, @Binding, @ObservedObject, and @EnvironmentObject
iOS & Swift2 min read

Differences between @State, @Binding, @ObservedObject, and @EnvironmentObject

Tests SwiftUI state ownership and propagation. @State owns local value types; @Binding borrows for two-way edits; @ObservedObject accepts an external ObservableObject; @EnvironmentObject reads one from the environment.

Compare UIKit Auto Layout and SwiftUI layout systems
iOS & Swift2 min read

Compare UIKit Auto Layout and SwiftUI layout systems

Tests imperative versus declarative layout paradigms. Contrast UIKit's constraint solver with SwiftUI's two-pass sizing and composition via stacks and modifiers instead of anchors. Red flag: claiming SwiftUI uses Auto Layout under the hood.

How do UITableView and UICollectionView reuse cells?
iOS & Swift2 min read

How do UITableView and UICollectionView reuse cells?

This tests your understanding of UIKit's flyweight pattern and scroll performance. A strong answer covers the reuse pool, dequeueReusableCell mapping identifiers to new index paths, and registration.

UIViewController lifecycle states: network vs geometry updates
iOS & Swift2 min read

UIViewController lifecycle states: network vs geometry updates

Tests UIViewController lifecycle states and separation of data vs layout. Strong answers list loadView to viewDidDisappear, start network in viewDidLoad or viewWillAppear, and geometry in viewDidLayoutSubviews. Red flag: network calls inside layout methods.