Skip to content

dev-Lena/Coordinator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Coordinator


Hits

👉🏻 간단한 예제로 살펴보는 iOS Design/Architecture Pattern: Coordinator - Basic

👉🏻 간단한 예제로 살펴보는 iOS Design/Architecture Pattern: Coordinator - Advanced

Coordinator란?

Soroush Khanlou가 NSSpain conference 2015에서 iOS 커뮤니티에 소개한 패턴으로 Soroush Khanlou 의 글에 보면 코디네이터(Coordinator)를 이렇게 소개하고 있습니다.

So what is a coordinator? 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.

코디네이터란? 코디네이터는 하나 이상의 뷰 컨트롤러에게 지시를 내리는 객체입니다. ... 이하 생략

여기서 말하는 지시는 화면 전환에 대한 지시를 말합니다. Coordinator 패턴에서는 현재 View Controller에서 다음 View Controller로 이동할 때 직접 push / present 등의 화면 전환을 하는 대신 모든 화면 내비게이션을 코디네이터가 관리합니다. 즉, View Controller에서 Navigation의 책임을 다른 클래스로 분리합니다. 따라서 View Controller들이 서로 분리될 수 있고 쉽게 재사용될 수 있습니다.

Coordinator 특징

  • coordinator 별로 하나 또는 그 이상의 View Controller를 보유합니다.
  • 각 coordinator는 일반적으로 “start”라고 불리는 메서드를 사용하여 View Controller를 표시합니다.
  • 각 View Controller에는 coordinator에 대한 delegate reference가 있습니다.
  • 각 coordinator는 child coordinators 배열을 가지고 있습니다.
  • 각 child coordinator는 parent coordinator에 대한 delegate reference가 있습니다.


더 자세한 내용은 블로그에 적어놨습니다.



예시 화면

alt text

  • 이 예제는 How to use the coordinator pattern in iOS appsAdvanced coordinators in iOS를 참고하여 만들었습니다.
  • ViewController의 UI는 Main.Storyboard에 구현했으며 storyboardId를 사용합니다.
  • Navigation Controller을 기반으로 화면을 전환합니다.
  • SceneDelegate를 삭제후 AppDelegate만을 사용합니다. (반드시 SceneDelegate를 삭제해야하는 것은 아닙니다. 이와 관련된 내용은 이슈 Initial Setting #4를 참고해주세요.)

하나의 Coordinator를 사용하는 방법은 Basic을, 여러 개의 Coordinator를 사용하는 방법은 Advanced를 확인해주세요.



Coordinator - Basic

image

  • 구현 과정은 PR 에 커밋으로 남겨놓았습니다.
  • Basic에서는 childCoordinators를 사용하지 않고 하나의 Coordinator를 사용합니다.

👉🏻 간단한 예제로 살펴보는 iOS Design/Architecture Pattern: Coordinator - Basic


Coordinator - Advanced

image

  • 구현 과정은 PR 에 커밋으로 남겨놓았습니다.

  • Advanced에서는 두 개이상의 Coordinator를 사용하는 방법을 간단하게 소개합니다. Coordinator 객체 간 child와 parent 관계 정리하는 방법이 소개되어 있습니다.

👉🏻 간단한 예제로 살펴보는 iOS Design/Architecture Pattern: Coordinator - Advanced

About

about Coordinator Pattern

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages