Skip to content

iOS sample app with MVVM and VIPER architectures.

License

Notifications You must be signed in to change notification settings

rvndios/MVVM-VIPER

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MVVM-VIPER

iOS sample app with MVVM and VIPER architectures.

Add snippet for Quick Protocol creationn for VIPER Architecture in XCode is here VIPER_PROTOCOL

VIPER 🐍

V - View I - Interactor P - Presenter E - Entiy R - Router

For VIPER architectural pattern protocol plays important role. Mainly for share data between the VIPER. Quick snippet for VIPER protocol

protocol PresenterProtocol: AnyObject{
    var view: ViewProtocol? {get set}
    var interactor: InteractorProtocol? {get set}
    var router: RouterProtocol? {get set}
}

protocol ViewProtocol: AnyObject{
    func updateUI<Model>(array: Array<Model>)
    func showError(_ error: AppError)
}

protocol RouterProtocol: AnyObject {
    static func createModule()
    func pushToScreen(viewControllerID: String, navigationConroller: UINavigationController)
    func performSegue(segueID: String)
}

protocol InteractorProtocol: AnyObject {
    var presenter: PresenterProtocol? {get set}
    func fetchData()
}

// MARK: Delegates
protocol InteractoDelegate: AnyObject {
    func fetchDataSuccess<Model>(noticeModelArray:Array<Model>)
    func fetchDataFailed(_ error: InteractorError)
}

Presenter used to bind all files together.

static func bind(_ view: ListViewController) -> PresenterProtocol  {
        let presenter: PresenterProtocol & InteractoDelegate = Presenter()
        let interactor: InteractorProtocol = Interactor()
        interactor.delegate = presenter
        let router: RouterProtocol = Router()
        
        view.presentor = presenter
        presenter.view = view
        presenter.router = router
        presenter.interactor = interactor
        interactor.presenter = presenter
        return presenter
    }

Interactor is main business logic class to access API and other data and pass to presenter for processing. Presenter will process and update data in the view. Router is for navigation logics like push from main page to detail page. Entity - Model class for the data we are using.

About

iOS sample app with MVVM and VIPER architectures.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages