This repository demonstrates the implementation of the MVVM-C (Model-View-ViewModel-Coordinator) architecture in iOS applications. MVVM-C enhances the traditional MVVM pattern by introducing Coordinators, which handle navigation and flow between screens.
- View: Handles UI components.
- ViewModel: Mediates between View and Model, providing data for the UI.
- Coordinator: Manages navigation flow, decoupling ViewControllers from handling transitions.
- Coordinator: The Coordinator handles navigation and manages the creation of the ViewModel and View (ViewController). It controls transitions between screens and is responsible for starting and coordinating flows.
- Create ViewModel: Implement the business logic adhering to
ViewModelProtocol
. The ViewModel processes data and prepares it for the View. - Create View: Build your UI in a
UIViewController
. The Coordinator injects the ViewModel into the View to handle data presentation and UI updates.
- Coordinators instantiate ViewModels and ViewControllers.
- ViewControllers bind to ViewModels for data presentation.
- Coordinators handle navigation actions triggered by the ViewModel.
- Coordinator starts a flow by creating a
ViewController
andViewModel
. - ViewModel provides data to the ViewController.
- The user interacts with the View, and actions are sent to the ViewModel.
- The Coordinator responds to navigation events, managing transitions between screens.
- Separation of Concerns: Each component has a clear responsibility.
- Testability: ViewModel and business logic are easily testable.
- Scalability: Coordinators simplify complex navigation flows, improving code maintainability.
- View: Contains the UI components.
- ViewModel: Exposes data for the view and handles the state.
- Coordinator: Manages navigation and transitions between views.
To clone and run the project, use:
git clone https://github.com/gorkemgur/MVVMC.git
cd MVVMC
open mvvmc.xcodeproj