Large number of view controllers and SceneCoordinator

Do you know any good solution for SceneCoordinator with large number of view controllers? @fpillet

The best solution IMHO is to divide your application in areas, use an enum for each, then a master enum that points to the appropriate area:

enum Scene {
  case main(MainScene)
  case settings(SettingsScene)
}

enum MainScene {
  case home
  case items
  case search

  fileprivate func viewController() -> UIViewController {
    switch self {
      // return the appropriate VC here
    }
  }
}

enum SettingsScene {
  case userSettings
  case regionSettings
  case appSettings

  fileprivate func viewController() -> UIViewController {
    switch self {
      // return the appropriate VC here
    }
  }
}

extension Scene {
  func viewControler() -> UIViewController {
   switch self {
     case .main(let mainScene):
       return mainScene.viewController()
     case .settings(let settingsScene):
       return settingsScene.viewController()
   }
  }
}
1 Like

You’re the boss! thank you :slight_smile: