Why must the View in MVP be a protocol?
The point
The Presenter in MVP updates the View, so it needs a reference to it. If that reference is a UIViewController, the Presenter:
- imports UIKit and drags the whole framework along;
- cannot be tested without instantiating the controller (hence without the simulator and loading the view);
- is tied to one specific screen.
So the View is described by a protocol — the set of commands the Presenter actually needs (show(count:), showError). That is DIP: the Presenter (high level) owns the abstraction; the controller (a detail) implements it.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep