본문 바로가기
IOS

[iOS] Coordinator 패턴 - 에이젠

by eigen96 2022. 8. 24.
728x90

iOS의 MVVM을 처음 공부할 때 MVVM-C를 적용하는 글을 종종 보았는데요.

C가 바로 코디네이터를 말하는 것이었습니다.

MVVM을 그대로 가져가면서 뷰 컨트롤러의 계층 관리를 따로 코디네이터가 하게 되는 것이죠.

 

언제 어디서나 쉽게 떠올릴 수 있도록 한번 정리해보겠습니다.

 

https://khanlou.com/2015/10/coordinators-redux/

 

Khanlou | Coordinators Redux

October 5, 2015 Coordinators Redux I wrote about coordinators at the beginning of the year, but the idea has matured a lot since then, and I’d like to reintroduce the topic with all of my learnings from the last few months. This is adapted from a talk I

khanlou.com

 

Coordinator Pattern?

A coordinator is an object that bosses one or more view controllers around.
Taking all of the driving logic out of your view controllers,
and moving that stuff one layer up is gonna make your life a lot more awesome.

코디네이터는 뷰 컨트롤러들을 통제하는 객체로서 소개가 됩니다.

 

어떻게 뷰컨을 통제할까?

그 동안 뷰 컨트롤러의 화면전환은 뷰 컨트롤러 내에 메소드(present, push)를 통해 처리해왔습니다.

코디네이터에게 이러한 transition의 책임을 넘겨줌으로서

뷰 컨트롤러 간 의존성을 없애주고 뷰컨트롤러 계층을 관리를 코디네이터가 하게됩니다.

 

 

728x90

댓글