Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MVCからVIPERへのリファクタに入門した話

Avatar for Shoryu0831 Shoryu0831
November 29, 2019

 MVCからVIPERへのリファクタに入門した話

VIPERへのリファクタをする時に、悩んだところについて説明しました。

Avatar for Shoryu0831

Shoryu0831

November 29, 2019

Other Decks in Technology

Transcript

  1. import UIKit final class menuViewController { private authenticated: Bool =

    false //ུ override func viewDidLoad() { presenter.getAuth(authenticated) //͜͜Ͱauthenticatedͷ੾Γସ͑ } //ུ ϩάΠϯঢ়گΛͲ͜Ͱ͔࣋ͭ
  2. Viewͷ੹຿͸ • Cheesecake LabsͷUsing VIPERʹΑΔͱɻɻ
 Its sole responsibility is to

    display what the Presenter tells it to, and handle the user interactions with the screen. 
 (https://cheesecakelabs.com/blog/ios-project-architecture-using-viper/ΑΓҾ༻) • Viewͷ໾ׂ͸Presenter͕఻͑ͨ௨Γʹදࣔ͢ΔͷͱɺUI ͷૢ࡞Λॲཧ͢Δ͜ͱɻ

  3. ॻ͖׵͑ޙ - Presenter import Foundation final class MenuPresenter { private

    var authenticated: Bool = false } // ུ extension MenuPresenter: MenuInteractorDelegate { func didFetchLoggedIn(_ loggedIn: Bool) { self.authenticated = loggedIn } func updateSettingList() { if authenticated { view.updateList() } } }
  4. ॻ͖׵͑ޙ - View import UIKit final class menuViewController { private

    authenticated: Bool = false //ུ override func viewDidLoad() { presenter.getAuth(authenticated) } func updateList() { // ϦετΛߋ৽͢Δ //ུ