View
- delegates user interaction events to thePresenter
and displays data passed by thePresenter
- All
UIViewController
,UIView
,UITableViewCell
subclasses belong to theView
layer - Usually the view is passive / dumb - it shouldn't contain any complex logic
Presenter
- contains the presentation logic and tells theView
what to present- Usually we have one
Presenter
per scene (view controller) - It doesn't reference the concrete type of the
View
, but rather it references theView
protocol that is implemented usually by aUIViewController
subclass - It should be a plain
Objective-c
class and not reference anyiOS
framework classes - this makes it easier to reuse Configurator
/Assembly
- injects the dependency object graph into the scene (view controller)- You could very easily use a DI (dependency injection) library. Typhoon is used here.
Router
- contains navigation / flow logic from one scene (view controller) to another- In some communities / blog posts it might be referred to as a
FlowController
- It is usually referenced only by the
Presenter
UseCase / Interactor
- contains the application / business logic for a specific use case in your application- It is referenced by the
Presenter
. ThePresenter
can reference multipleUseCases
since it's common to have multiple use cases on the same screen - It manipulates
Entities
and communicates withGateways
to retrieve / persist the entities - The
Gateway
protocols should be defined in theApplication Logic
layers and implemented by theGateways & Framework Logic
- The separation described above ensures that the
Application Logic
depends on abstractions and not on actual frameworks / implementations Entity
- plain ``Objective-C` classes- Models objects used by your application such as
Order
,Product
,Shopping Cart
, etc
Gateway
- contains actual implementation of the protocols defined in theApplication Logic
layer- We can implement for instance a
LocalPersistenceGateway
protocol usingCoreData
,Realm
,Sqlite
, or even simple usefile system
- We can implement for instance an
ApiGateway
protocol usingURLSession
,AFNetworking
or other. - We can implement for instance a
UserSettings
protocol usingUserDefaults
Persistence / API Entities
- contains framework specific representationsFramework specific APIs
- contains implementations ofiOS
specific APIs such as sensors / bluetooth / camera
- Specta used for Unit testing