PrepPilotPractise free

iOS & Swift interview questions

Swift, SwiftUI/UIKit, concurrency, memory, app lifecycle

18 questions · SwiftUI · updated November 2026

Practise these as flashcards. One or two lines each; the ones you miss come back first.

Start free

Core questions

What is the difference between a struct and a class in Swift?

Structs are value types, so they are copied when assigned or passed. Classes are reference types, so variables refer to the same instance. Also, only classes support inheritance and deinitializers.

How do you safely unwrap an optional in Swift?

I use if let or guard let to safely unwrap optionals, which prevents runtime crashes from nil values. For example, if let name = user.name { print(name) }.

What does the weak keyword do?

weak creates a non-owning reference to an object, preventing retain cycles. It's commonly used for delegates or back-references in closures.

How do you make a struct conform to a protocol?

You declare conformance in the struct's definition, like struct Car: Drivable { ... }, and implement the protocol's required methods and properties.

What is TestFlight used for?

TestFlight is Apple's beta testing platform. It lets you distribute pre-release versions of your app to testers before submitting to the App Store.

Intermediate questions

Explain how @State and @ObservedObject work in SwiftUI.

@State is used for simple, local state owned by a view. @ObservedObject is for referencing an external, observable object that conforms to ObservableObject, allowing the view to react to its changes.

How does ARC work in Swift?

ARC automatically manages the memory of class instances by keeping track of strong references. When an instance's reference count drops to zero, it's deallocated. Retain cycles can prevent this, so we use weak or unowned to break them.

How do you perform a network request and decode JSON in Swift?

I use URLSession to make the request, then decode the response using Codable and JSONDecoder. For example, I create a model conforming to Codable and call JSONDecoder().decode(Model.self, from: data).

What is the role of the MainActor in Swift concurrency?

MainActor ensures that code runs on the main thread, which is required for UI updates. By annotating functions or classes with @MainActor, I guarantee thread safety for UI-related code.

Describe how you would persist user data locally in an iOS app.

For structured data, I use Core Data or SwiftData, which provide object graph management and persistence. For simpler needs, I might use UserDefaults or write Codable models to disk.

How do you test a view model in Swift?

I use XCTest to write unit tests for the view model's logic. I inject dependencies, use mocks for services, and assert that the view model produces the expected outputs for given inputs.

What steps are involved in releasing an app to the App Store?

I increment the version, archive the app in Xcode, upload it via Organizer, and submit it for review. I also use TestFlight for beta testing and ensure all assets and metadata are complete.

What is Codable and how does it work?

See the answer in the app, free

Senior questions

How would you debug a memory leak caused by a retain cycle in a Swift app?

See the answer in the app, free

Compare state management in SwiftUI and UIKit for a complex form.

See the answer in the app, free

How would you architect a networking layer that supports async/await and is testable?

See the answer in the app, free

Describe how you would handle background data fetches in an iOS app.

See the answer in the app, free

How do actors help prevent data races in Swift concurrency?

See the answer in the app, free

More Mobile topics