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

Fat ViewControllerを倒せ!
〜Cocoa MVC への道のり〜 / No M...

Fat ViewControllerを倒せ!
〜Cocoa MVC への道のり〜 / No More Fat ViewController! ~The path to Cocoa MVC~

Elvis Shi

May 30, 2020
Tweet

More Decks by Elvis Shi

Other Decks in Programming

Transcript

  1. } var employedBy = "YUMEMI Inc." var job = "iOS

    Tech Lead" var favoriteLanguage = "Swift" var twitter = "@lovee" var qiita = "lovee" var github = "el-hoshino" var additionalInfo = """ Twitter෮׆ͨ͠ʂ """ final class Me: Developable, Talkable {
  2. मਖ਼ํ޲ʢσʔλϑϩʔʣ w ॲཧͷྲྀΕΛҰຊಓԽ w BoardView͕ϢʔβΞΫγϣϯΛड͚ͨΒ@IBAction΋ ͘͠͸delegate௨ͯ͠ViewControllerʹ఻ୡ w ViewController͕΋ΒͬͨϢʔβΞΫγϣϯΛݩʹ GameEngineΛૢ࡞ w

    GameEngine͕ಠࣗઐ༻εϨουͰૢ࡞Λॲཧ͠ɺͦͷ݁Ռ ΛAnyPublisherͰViewControllerʹ௨஌ w ViewController͕΋Βͬͨ݁ՌΛݩʹϝΠϯεϨουͰ BoardViewΛߋ৽ w BoardView͕ͦͷ݁Ռͷ௨Γʹඳը
  3. $PDPB.7$ͷߏ੒ 7JFX$POUSPMMFS (BNF&OHJOF #PBSE7JFX reset() setPlayer(_:for:) getPlayer(for:)-> placeDisk(at:) nextMove() currentBoard{get}

    saveGame() loadGame() $isThinking $changedDisks $currentTurn $currentCount boardSize{set} changeDisks(at:to:) reset(with:) @pressReset(_:) @changePlayerControl(_:) .didSelectCell(at:) $AnyPublisherͱͯ͠ฦ͞ΕΔ @@IBActionΛ௨ͯ͠ݺ͹ΕΔ .delegateΛ௨ͯ͠ݺ͹ΕΔ
  4. ͦͷଞ w $PDPB.7$ͷߏ੒ͷઆ໌͚ͩͳͷͰɺGameEngine ͕·ͩগʑ'BU w GameEngineΛ७ਮؔ਺Խͯ͠ɺ֤छঢ়ଶΛ͞Βʹ GameStoreͱ͔ʹ੾Γग़ͤ͹ߋʹ͖Ε͍ʹͳΔ w ΍ͬͺ6*,JUʹͱͬͯ$PDPB.7$͸ָʂ w

    protocolͰ@Published<Value>ͱ͔ΛએݴͰ͖Δ Α͏ʹͯ͠΄͍͠ w ࠓ͸AnyPublisher<Value, Never> { get }Ͱ ఆٛ͢Δ͔͠ͳ͍ͷ͕ඍົʹਏ͍