SwiftPumpkin

3 of 22 · UI patterns

MVP (Passive View)

MVP (Model–View–Presenter) makes the view passive: it forwards events and executes display commands, while a Presenter holds all presentation logic and talks to the view through a protocol.

How it's wired

EventsDisplay commandsCallsResultsView (passive)Displays, forwards eventsPresenterAll presentation logicModelData + domain logic
calls or tellsreports backThe presenter pushes commands through a view protocol. The view holds no state of its own.
  • View ↔ Presenter through a protocol (MVPNoteView).
  • The presenter pushes commands like setSaveEnabled into the view.
PartOwnsLooks like
ViewForward events, execute display commandsUIViewController: NoteView protocol
PresenterDecide what to show, hold weak viewPlain class, no UIKit
ModelDomain data, rules, servicesStructs, services

Where MVP breaks down

  • The view protocol grows with every label: setTitle, setSaveEnabled, showError, showSpinner. A 40-method view protocol is a sign the screen should be split.
  • Commands drift from state. The presenter pushes deltas, so there's no single snapshot of what the screen shows. Rotation, restoration or cell reuse means replaying commands correctly. MVVM's state-based binding avoids this class of bug.
  • Lifecycle bleeds in. Presenters start mirroring viewDidLoad and viewWillAppear. Keep those calls few and named by intent (screenDidAppear, retryTapped).

When I'd use MVP

UIKit codebase, no reactive layerMVP gives testable presenters with zero framework.
SwiftUI or @Observable availableMVVM. State binding beats command replay.

Compared

MVP vs MVVM

MVP
ViewPresenterModel

Presenter pushes commands into a passive view.

MVVM
ViewViewModelModel

View binds to state the ViewModel exposes.

MVPMVVM
Talks to the view viaCommands through a protocolState the view observes
Screen's source of truthSpread across commandsViewModel state
TestingFake view records callsAssert on state
FitsUIKit, no binding frameworkSwiftUI, @Observable, Combine

Expert notes

  • The crisp distinction interviewers want: MVP pushes commands, MVVM exposes state. Everything else follows from that.

Check yourself

Answer out loud before you reveal. Recall is what makes it stick.

30-second answer

Explain MVP (Passive View) in 30 seconds.

iOS codingAsked directly

What is Passive View, and how does it differ from Supervising Controller?

iOS codingAsked indirectly

You need to unit-test form validation and error display without instantiating UIKit. How do you structure the screen?

System designAsked indirectly

Two screens show the same model and must both update when it changes. Observer synchronization or explicit flow synchronization?

Read it in the app's source