ç§ã䜿çšããRouteComposerã©ã€ãã©ãªãŒã«é¢ããäžé£ã®èšäºãç¶ããŠããŸãããä»æ¥ã¯Coordinatorãã¿ãŒã³ã«ã€ããŠã話ããããšæããŸãã ãã¿ãŒã³ã«é¢ããèšäºã®1ã€ãè°è«ããããšã§ããã®èšäºãæžãããä¿ãããŸããã
å°ãåã«å°å ¥ãããCoordinatorãã¿ãŒã³ã¯ãiOSéçºè ã®éã§ãŸããŸã人æ°ãåŸãŠãããäžè¬çã«ããã®çç±ã¯æããã§ãã UIKitãæäŸããããã«äœ¿ããããŒã«ã¯ãæ®éçãªæ··ä¹±ã§ã¯ãªãããã§ãã
ç§ã¯ãã§ã«ãã¹ã¿ãã¯äžã®ã³ã³ãããŒã©ãŒã®ãã¥ãŒãæ§æããæ¹æ³ã®æçåã®åé¡ãæèµ·ããŠããŸã ãç¹°ãè¿ããé¿ããããã«ã ããã§ããã«ã€ããŠèªãããšãã§ããŸã ã
æ£çŽã«èšã£ãŠãã ããã ããæç¹ã§ãEpoleã¯ã³ã³ãããŒã©ãŒãã¢ããªã±ãŒã·ã§ã³éçºã»ã³ã¿ãŒã«é
眮ããããšã§ãã³ã³ãããŒã©ãŒéã§ããŒã¿ãäœæãŸãã¯è»¢éããããã®è³¢æãªæ¹æ³ãæäŸããªãã£ãããšã«æ°ä»ããŸãããããæç¹ã§ãã¹ããŒãªãŒããŒããšã»ã°ãšã玹ä»ããŠãããŸããã ãã®åŸãEpolusã¯èªåã2ã€ã®ç»é¢ã ãã§æ§æãããã¢ããªã±ãŒã·ã§ã³ãæžããŠããããšã«æ°ã¥ãã次ã®å埩ã§ã¯ãã¹ããŒãªãŒããŒããç¹å®ã®ãµã€ãºã«éãããšXcodeãã¯ã©ãã·ã¥ãå§ãããããã¹ããŒãªãŒããŒããããã€ãã®ã³ã³ããŒãã³ãã«åå²ããå¯èœæ§ãææ¡ããŸããã ã»ã°ãšã¯ããã®æŠå¿µã«æ²¿ã£ãŠãäºãã«ããŸãäºææ§ã®ãªãããã€ãã®å埩ã§å€æŽãããŸããã ãããã®ãµããŒãã¯ã倧èŠæš¡ãªUIViewController
ã¯ã©ã¹ã«ãã£ãããšçž«ãä»ããããŠãããæçµçã«ã¯åŸããã®ãæã«å
¥ããŸããã ããã«ãããŸãïŒ
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "showDetail" { if let indexPath = tableView.indexPathForSelectedRow { let object = objects[indexPath.row] as! NSDate let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController controller.detailItem = object controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem controller.navigationItem.leftItemsSupplementBackButton = true } } }
ãã®ã³ãŒããããã¯ã®ãã©ãŒã¹ã¿ã€ãã£ã¹ããã£ã¹ãã®æ°ã¯é©ãã¹ããã®ã§ããã¹ããŒãªãŒããŒãèªäœã®æååå®æ°ããXcodeããŸã£ããæ段ãæäŸããŠããªãããšã远跡ããããã®ãã®ã§ãã ãããŠãããã²ãŒã·ã§ã³ããã»ã¹ã§äœããå€æŽããããšããããããªæ¬²æ±ã«ãããäœã®åªåãããã«ãããžã§ã¯ããã³ã³ãã€ã«ããããšãã§ããXcodeããã®ããããªèŠåãªãã§å®è¡æã«çªç¶ã¯ã©ãã·ã¥ããŸãã ãããæçµçã«å€æãããã®ãããªWYSIWYGã§ãã ããªããèŠããã®ã¯ããªããåŸããã®ã§ãã
ã¹ããŒãªãŒããŒãã®ãããã®ç°è²ã®ç¢å°ã®é åã«ã€ããŠã¯ãç»é¢éã®æ¥ç¶ã誰ãã«ç€ºããŠãããšé·ãéè°è«ã§ããŸãããç§ã®å®è·µã瀺ããŠããããã«ããããžã§ã¯ãã5ã6ç»é¢ãè¶ ããŠããã«ãããŸããŸãªäŒç€Ÿã®ããã€ãã®ããç¥ãããŠããéçºè ã«æå³çã«ã€ã³ã¿ãã¥ãŒããŸããããä¿¡é Œæ§ã®é«ããœãªã¥ãŒã·ã§ã³ãèŠã€ããŠãããããView Controllerã®ã¹ã¿ãã¯ã®æ§é ãé ã®äžã«ä¿æãå§ããŸããã ãŸããiPadããã®ä»ã®ããã²ãŒã·ã§ã³ã¢ãã«ã®ãµããŒããããã·ã¥ã®ãµããŒããè¿œå ãããå Žåããã¹ãŠãæ²ãããªããŸããã
ãã以æ¥ããã®åé¡ã解決ããããã«ããã€ãã®è©Šã¿ãè¡ãããŸãããããã®äžã«ã¯View Controllerå ã«View Controllerãäœæãããšãã®å·šå€§ã§äžåšçšãªã³ãŒããããã«äœæããããããããã€ãã¯å¥ã ã®ãã¬ãŒã ã¯ãŒã¯ãå¥ã ã®ã¢ãŒããã¯ãã£ãã¿ãŒã³ã«ãªããŸããã
ã³ãŒãã£ããŒã¿ãŒãã¿ãŒã³ã«æ»ããŸãããã æãããªçç±ã§ãWikipediaã«ã¯æšæºã®ããã°ã©ãã³ã°/ãã¶ã€ã³ãã¿ãŒã³ã§ã¯ãªãããããã®èª¬æã¯ãããŸããã ããããããã¯äžçš®ã®æœè±¡åã§ãããã¹ã¿ãã¯ã«æ°ããã³ã³ãããŒã©ãŒãã€ã¹ããäœæããŠæ¿å ¥ããã³ã³ãããŒã©ãŒã³ã³ãããŒãžã®åç §ãä¿åããã³ã³ãããŒã©ãŒéã§ããŒã¿ãããã·ã¥ããããã®ãã®ãugããã³ãŒãããã¹ãŠé ããŸãã ãã®ããã»ã¹ã説æããæãé©åãªèšäºã¯ã raywenderlich.comã®èšäºãåŒã³åºããŸãã 2015幎ã®NSSpainäŒè°ã®åŸãäžè¬å€§è¡ã«ãã®ããšãäŒããããåŸã人æ°ãåºå§ããŸããã 詳现ã«ã€ããŠã¯ã ãããšããã«èšèŒãããŠããŸã ã
次ã«é²ãåã«ããã®æ§æãç°¡åã«èª¬æããŸãã
ãã¹ãŠã®è§£éã«ãããã³ãŒãã£ããŒã¿ãŒãã¿ãŒã³ã¯ããã®å³ã«ã»ãŒé©åããŠããŸãã
ã€ãŸããã³ãŒãã£ããŒã¿ãŒã¯ãããã³ã«ã§ã
protocol Coordinator { func start() }
ãããŠããã¹ãŠã®codeãã³ãŒãã¯start
é¢æ°ã«é ãããŠããã¯ãã§ãã ããã«ãã³ãŒãã£ããŒã¿ãŒã¯åã³ãŒãã£ããŒã¿ãŒãžã®ãªã³ã¯ãæã€ããšãã§ããŸããã€ãŸããæ§æããèœåããããããšãã°ãããå®è£
ãå¥ã®å®è£
ã«çœ®ãæããããšãã§ããŸãã ã€ãŸããããªããšã¬ã¬ã³ãã«èãããŸãã
ããããäžå¹žã¯ããã«å§ãŸããŸãïŒ
- ããã€ãã®å®è£
ã§ã¯ãç¹å®ã®çæãã¿ãŒã³ããã³ãŒãã£ããŒã¿ãŒãããåççãªãã®ã«å€ããã³ã³ãããŒã©ãŒã®ã¹ã¿ãã¯ãã¢ãã¿ãŒããã³ã³ãããŒã®ããªã²ãŒã ïŒ
UINavigationController
ãªã©ïŒã«ããŠãæ»ããã¿ã³ã®ã¯ãªãã¯ãåŠçããããåã³ãŒãã£ããŒã¿ãŒãã¹ã¯ã€ãããŠåé€ããããšãUINavigationController
ããŠããŸãã èªç¶ãªçç±ã«ããã1ã€ã®ãªããžã§ã¯ãã®ã¿ãããªã²ãŒãã«ãªããŸããããã«ãããã³ã³ãããŒèªäœã®å¶åŸ¡ãå¶éããããã®ããžãã¯ãã³ãŒãã£ããŒã¿ãŒã«ãããããã®ããžãã¯ããªã¹ãã®äžã®æ¹ã«ããã«å§ä»»ããå¿ èŠãçããŸãã - å€ãã®å Žåã次ã®ã³ã³ãããŒã©ãŒãäœæããããã®ããžãã¯ã¯ããžãã¹ããžãã¯ã«äŸåããŸãã ããšãã°ã次ã®ç»é¢ã«é²ãã«ã¯ããŠãŒã¶ãŒãã·ã¹ãã ã«ãã°ã€ã³ããå¿ èŠããããŸãã æããã«ãããã¯éåæããã»ã¹ã§ããããã°ã€ã³ãã©ãŒã ã䜿çšããäžéç»é¢ã®çæãå«ãŸããŸãããã°ã€ã³ããã»ã¹èªäœã¯æ£åžžã«çµäºãããã©ãããç°ãªããŸãã CoordinatorãMassive Coordinatorã«å€ããã®ãé¿ããããã«ïŒMassive View Controllerãšã®é¡æšã«ããïŒãå解ãå¿ èŠã§ãã ã€ãŸããå®éã«ã¯ãã³ãŒãã£ããŒã¿ãŒã®ã³ãŒãã£ããŒã¿ãŒãäœæããå¿ èŠããããŸãã
- ã³ãŒãã£ããŒã¿ãŒãçŽé¢ããå¥ã®åé¡ã¯ã
UINavigationController
ãUITabBarController
ãªã©ã®ã³ã³ãããŒãã¥ãŒã³ã³ãããŒã©ãŒã®ã©ãããŒã§ããããšã§ãã ãããŠã誰ãããããã®ã³ã³ãããŒã©ãŒãžã®ãªã³ã¯ãæäŸããå¿ èŠããããŸã ã åã³ãŒãã£ããŒã¿ãŒã䜿çšããŠããã¹ãŠãå€å°æ確ã§ãªãå Žåããã§ãŒã³ã®æåã®ã³ãŒãã£ããŒã¿ãŒã䜿çšãããšããã¹ãŠãããã»ã©åçŽã§ã¯ãããŸããã ããã«ãA / Bãã¹ããªã©ã®ããã²ãŒã·ã§ã³ãå€æŽããå Žåããã®ãããªã³ãŒãã£ããŒã¿ãŒã®ãªãã¡ã¯ã¿ãªã³ã°ãšé©å¿ã«ãããå¥ã®é çãçããŸãã ç¹ã«ãã³ã³ããã®ã¿ã€ããå€æŽãããå Žåã - ããããã¹ãŠã¯ãã¢ããªã±ãŒã·ã§ã³ãView Controllerãçæããå€éšã€ãã³ãã®ãµããŒããéå§ãããšããã«è€éã«ãªããŸãã ããã·ã¥éç¥ããŠãããŒãµã«ãªã³ã¯ãªã©ïŒãŠãŒã¶ãŒãã¬ã¿ãŒå
ã®ãªã³ã¯ãã¯ãªãã¯ãã察å¿ããã¢ããªã±ãŒã·ã§ã³ç»é¢ã§ç¶è¡ããŸãïŒã ããã§ãã³ãŒãã£ããŒã¿ãŒãã¿ãŒã³ã«æ£ç¢ºãªçãããªãä»ã®äžç¢ºå®æ§ãçããŸãã å€éšã€ãã³ãã«ãã£ãŠèŠæ±ããã次ã®ç»é¢ããŠãŒã¶ãŒã«è¡šç€ºããã«ã¯ããŠãŒã¶ãŒãçŸåšã©ã®ç»é¢ã«ããã®ããæ£ç¢ºã«ç¥ãå¿
èŠããããŸãã
æãç°¡åãªäŸã¯ã3ã€ã®ç»é¢ïŒãã£ãããªã¹ãããã£ãããªã¹ãã³ã³ãããŒã©ãŒã®ããã²ãŒã·ã§ã³ã«ããã·ã¥ããããã£ããèªäœãããã³ã¢ãŒãã«ã§è¡šç€ºãããèšå®ç»é¢ïŒã§æ§æããããã£ããã¢ããªã±ãŒã·ã§ã³ã§ãã ãŠãŒã¶ãŒã¯ãããã·ã¥éç¥ãåä¿¡ããŠââã¿ãããããšããããã®ç»é¢ã®ããããã«ã¢ã¯ã»ã¹ã§ããŸãã ãããŠãããã§äžç¢ºå®æ§ãå§ãŸããŸãã圌ããã£ãããªã¹ãã«ããå Žåããã®ç¹å®ã®ãŠãŒã¶ãŒãšãã£ãããéå§ããå¿ èŠããããŸãã圌ãæ¢ã«ãã£ããã«ããå Žåããããåãæ¿ããå¿ èŠãããã圌ãæ¢ã«ãã®ãŠãŒã¶ãŒãšãã£ããããŠããå Žåãäœãããã«æŽæ°ããŸãããŠãŒã¶ãŒããªã³ã®å Žåèšå®ç»é¢-ãããæããã«ããªãã¯éããŠãåã®æé ã«åŸãå¿ èŠããããŸãã ãŸãã¯ãéããã«èšå®ã§ã¢ãŒãã«ã§ãã£ããã衚瀺ããããšãã§ããŸããïŒ ãããŠãèšå®ãã¢ãŒãã«ã§ã¯ãªãå¥ã®ã¿ãã«ããå Žåã¯ã©ããªããŸããïŒ ãããã¯ãã³ãŒãã£ããŒã¿ãŒã«ãã£ãŠåºããããããã¹ãã²ããã£ã®åœ¢ã§å¥ã®ã¡ã¬ã³ãŒãã£ããŒã¿ãŒã«è¡ããŸãã ããã«ãã³ã³ãããŒã©ãŒã¹ã¿ãã¯ã«å¯Ÿããã¢ã¯ãã£ããªå埩ãšããŠãŒã¶ãŒãçŸåšã©ãã«ããããå€æããè©Šã¿ããŸãã¯ãã®ç¶æ ãç£èŠããäœããã®çš®é¡ã®ã¢ããªã±ãŒã·ã§ã³ãæ§ç¯ããè©Šã¿ã®ããããã§ãããããã¯ã³ã³ãããŒã©ãŒã¹ã¿ãã¯èªäœã®æ§è³ªã«åºã¥ããç°¡åãªã¿ã¹ã¯ã§ã¯ãããŸããã - ãããŠãUIKitã®äžå
·åã¯ã±ãŒãã®ãã§ãªãŒã§ãã ç°¡åãªäŸïŒ2çªç®ã®ã¿ãã«
UINavigationController
ããããä»ã®UIViewController
ã æåã®ã¿ãã®ãŠãŒã¶ãŒã¯ãã¿ããåãæ¿ãUINavigationController
å¥ã®View ControllerãUINavigationController
ããå¿ èŠãããç¹å®ã®ã€ãã³ããçºçããUINavigationController
ã ããã¯ãã¹ãŠããŸãã«ãã®ãããªé åºã§å®è¡ããå¿ èŠããããŸãã ããããåã«ãŠãŒã¶ãŒã2çªç®ã®ã¿ããéããããšUINavigationController
ãªããviewDidLoad
UINavigationController
åŒã³åºãããªãã£ãviewDidLoad
ãpush
ã¡ãœããã¯æ©èœãããã³ã³ãœãŒã«ã«äžæçãªã¡ãã»ãŒãžã®ã¿ãæ®ããŸãã ã€ãŸãããã®äŸã§ã¯ãã³ãŒãã£ããŒã¿ãŒãåã«ã€ãã³ãã®ãªã¹ããŒã«ããããšã¯ã§ãããç¹å®ã®é åºã§åäœããå¿ èŠããããŸãã ãã®ããããäºãã®ç¥èãå¿ èŠã§ãã ãããŠããã¯ãã³ãŒãã£ããŒã¿ãŒã¯çæã³ãŒãã£ããŒã¿ãŒã«ã€ããŠäœãç¥ãããåã³ãŒãã£ããŒã¿ãŒã®ã¿ãšæ¥ç¶ããŠãããšããã³ãŒãã£ããŒã¿ãŒãã¿ãŒã³ã®æåã®ã¹ããŒãã¡ã³ããšã¯ãã§ã«ççŸããŠããŸãã ãŸããäºææ§ãå¶éãããŸãã
ãã®ãªã¹ãã¯ç¶ç¶ã§ããŸãããäžè¬çã«ãã³ãŒãã£ããŒã¿ãŒãã¿ãŒã³ãããªãå¶éãããæ¡åŒµæ§ã®äœããœãªã¥ãŒã·ã§ã³ã§ããããšã¯æããã§ãã ãã³ã¯è²ã®ã¡ã¬ããªãã§èŠããšãéåžžã倧èŠæš¡ãªUIViewController
å
ã«èšè¿°ãããŠããããžãã¯ã®äžéšãå¥ã®ã¯ã©ã¹ã«å解ããæ¹æ³ã§ãã åãªãçæçãªãã¡ã¯ããªãŒä»¥äžã®ãã®ãäœããããã«å¥ã®ããžãã¯ãæã¡èŸŒãããšããè©Šã¿ã¯ãã¹ãŠããŸããããŸããã
ãã®ãã¿ãŒã³ã«åºã¥ããã©ã€ãã©ãªãååšããããšã¯æ³šç®ã«å€ããŸãããããã®ã©ã€ãã©ãªã¯ãããçšåºŠã¯ãããã®æ¬ ç¹ãéšåçã«ç·©åããããšãã§ããŸãã XCoordinatorãšRxFlowã« èšåããŸã ã
ç§ãã¡ã¯äœãããŸãããïŒ
ãµããŒããšéçºã®ããã«å¥ã®ããŒã ããåŸããããžã§ã¯ãã«åå ããã³ãŒãã£ããŒã¿ãŒãšåœŒãã®ç°¡ç¥åããããgreatç¥æ¯ã ã«ãŒã¿ãŒãVIPERã¢ãŒããã¯ãã£ã¢ãããŒãã§äœ¿çšããŠãåœç€Ÿã®ä»¥åã®å€§èŠæš¡ãããžã§ã¯ãã§ããŸãæ©èœããã¢ãããŒãã«ããŒã«ããã¯ããŸããã ãã®ã¢ãããŒãã«ã¯ååããããŸããã ããã¯è¡šé¢ã«ãããŸãã 空ãæéããããšããããã¯å¥ã®RouteComposerã©ã€ãã©ãªã«ã³ã³ãã€ã«ãããã³ãŒãã£ããŒã¿ãŒãå®å šã«çœ®ãæããããæè»ã§ããããšã蚌æãããŸããã
ãã®ã¢ãããŒãã¯äœã§ããïŒ ãã®äžã§ãã¹ã¿ãã¯ïŒããªãŒïŒã«äŸåããããã«ãã³ã³ãããŒã©ãŒããã®ãŸãŸã²ãããŸãã åŸãå¿ èŠãããäžå¿ èŠãªãšã³ãã£ãã£ãäœæããªãããã æ¡ä»¶ãä¿åãŸãã¯è¿œè·¡ããªãã§ãã ããã
UIKitãšã³ãã£ãã£ããã詳ããèŠãŠã æçµçã«äœãããã®ãââãäœãæäœã§ããã®ããèããŠã¿ãŸãããã
- ã³ã³ãããŒã©ã¹ã¿ãã¯ã¯ããªãŒã§ãã åView Controllerãæã€ã«ãŒãView ControllerããããŸãã ã¢ãŒãã«ã§æ瀺ãããView Controllerã¯ãçæãããView Controllerãžã®ãã€ã³ãã£ã³ã°ãæã€ãããåView Controllerã®ç¹æ®ãªã±ãŒã¹ã§ãã ããã«äœ¿çšã§ããŸãã
- ã³ã³ãããŒã©ãŒã®æ¬è³ªãäœæããå¿ èŠããããŸãã ãããã¯ãã¹ãŠç°ãªãã³ã³ã¹ãã©ã¯ã¿ãŒãæã¡ãXibãã¡ã€ã«ãŸãã¯ã¹ããŒãªãŒããŒãã䜿çšããŠäœæã§ããŸãã ãããã«ã¯ç°ãªãå ¥åãã©ã¡ãŒã¿ãŒããããŸãã ãããããããã¯äœæãããå¿ èŠããããšããç¹ã§å£çµããŠããŸãã ããã§ãç®çã®View Controllerãäœæããæ¹æ³ãç¥ã£ãŠããFactoryãã¿ãŒã³ãã§ããŸããã åå·¥å Žã¯å æ¬çãªåäœãã¹ãã§ç°¡åã«ã«ããŒã§ããä»ã®å·¥å Žããã¯ç¬ç«ããŠããŸãã
- View Controllerã2ã€ã®ã¯ã©ã¹ã«åå²ããŸãïŒ1. Controllerã衚瀺ããã ãã§ãã2. Container View ControllerïŒContainer View ControllerïŒ ã ã³ã³ããView Controllerã¯ãåView Controllerãå«ããããšãã§ãããšããç¹ã§éåžžã®ãã®ãšç°ãªããŸã-ã³ã³ãããŸãã¯ã·ã³ãã«ãªãã®ãå«ãŸããŸãã ãã®ãããªView Controllerã¯ã
UITabBarController
ãUITabBarController
ãªã©ã®ããã¯ã¹ãã䜿çšã§ããŸããããŠãŒã¶ãŒãäœæããããšãã§ããŸãã ç¡èŠãããšããã¹ãŠã®ã³ã³ããã§æ¬¡ã®ããããã£ãèŠã€ããããšãã§ããŸãã1.å«ãŸããŠãããã¹ãŠã®ã³ã³ãããŒã©ã®ãªã¹ãããããŸãã 2. 1ã€ä»¥äžã®ã³ã³ãããŒã©ãŒãçŸåšè¡šç€ºãããŠããŸãã 3.ãããã®ã³ã³ãããŒã©ãŒã®ããããã衚瀺ããããã«æ±ããããå ŽåããããŸãã UIKitã³ã³ãããŒã©ãŒã§ã§ããããšã¯ããã ãã§ã ã 圌ãã¯ãã®ããã«ç°ãªãæ¹æ³ãæã£ãŠããŸãã ãã ããã¿ã¹ã¯ã¯3ã€ãããããŸããã - å·¥å Žã§äœæãããView Controllerãåã蟌ãããã«ãControllerã®èŠªViewã¡ãœããã¯
UINavigationController.pushViewController(...)
ãUITabBarController.selectedViewController = ...
ãUIViewController.present(...)
ã§ãã 2ã€ã®View Controllerãåžžã«å¿ èŠã§ããã1ã€ã¯æ¢ã«ã¹ã¿ãã¯äžã«ããããã1ã€ã¯ã¹ã¿ãã¯ã«åã蟌ãå¿ èŠãããããšã«æ°ä»ããããããŸããã ãããã©ãããŒã§ã©ãããã ActionïŒActionïŒãšåŒã³ãŸãã åã¢ã¯ã·ã§ã³ã¯å æ¬çãªåäœãã¹ãã§ç°¡åã«ã«ããŒã§ããããããã¯ä»ã®ã¢ã¯ã·ã§ã³ããç¬ç«ããŠããŸãã - äžèšãããæºåããããšã³ãã£ãã£ã䜿çšããŠãæ§æãã§ãŒã³ãæ§ç¯ã§ããããšãããããŸããFactory- > Action-> Factory-> Action-> FactoryãããŠãå®äºåŸãä»»æã®è€éãªã³ã³ãããŒã©ãŒã®ãã¥ãŒããªãŒãæ§ç¯ã§ããŸãã ãšã³ããªãã€ã³ããæå®ããã ãã§ãã éåžžããããã®å ¥åãã€ã³ãã¯ã UIWindowãææããrootViewControllerããããªãŒã®æã極端ãªãã©ã³ãã§ããçŸåšã®View Controllerã§ãã ã€ãŸãããã®ãããªæ§æã¯ã ViewController-> Action-> Factory-> ...-> Factoryã®ããã«æ£ããèšè¿°ãããŸãã
- æ§æã«å ããŠãæäŸãããæ§æãéå§ããã³æ§ç¯ããæ¹æ³ãç¥ã£ãŠãããšã³ãã£ãã£ãå¿ èŠã«ãªããŸãã ãããRouterãšåŒã³ãŸãã ç¶æ ããªãããªã³ã¯ãä¿æããŠããŸããã æ§æãæž¡ããã1ã€ã®ã¡ãœããããããæ§ææé ãé çªã«å®è¡ããŸãã
- ã€ã³ã¿ãŒã»ãã¿ãŒã¯ã©ã¹ãæ§æãã§ãŒã³ã«è¿œå ããŠãã«ãŒã¿ãŒã«è²¬ä»»ãè¿œå ããŸãã ã€ã³ã¿ãŒã»ãã¿ãŒã«ã¯æ¬¡ã®3çš®é¡ããããŸãã1.ããã²ãŒã·ã§ã³ãéå§ããåã«èµ·åããŸãã ã·ã¹ãã å ã®ãŠãŒã¶ãŒèªèšŒã¿ã¹ã¯ãšããã®ä»ã®éåæã¿ã¹ã¯ãåé€ããŸãã 2. View Controllerã®äœææã«å®è¡ããŠãå€ãèšå®ããŸãã 3.ããã²ãŒã·ã§ã³ããã³ããŸããŸãªåæã¿ã¹ã¯ã®å®è¡åŸã«å®è¡ãããŸãã åãšã³ãã£ãã£ã¯åäœãã¹ãã§ç°¡åã«ã«ããŒãããæ§æã§ã©ã®ããã«äœ¿çšããããããããŸããã 圌女ã«ã¯1ã€ã®è²¬ä»»ãããªãããããæãããŸãã ã€ãŸããè€éãªããã²ãŒã·ã§ã³ã®æ§æã¯ã [äºåããã²ãŒã·ã§ã³ã¿ã¹ã¯...]-> ViewControllerã®éå§->ã¢ã¯ã·ã§ã³->ïŒãã¡ã¯ããªãŒ+ [ContextTask ...]ïŒ-> ...->ïŒãã¡ã¯ããªãŒ+ [ContextTask ...]ïŒ-> [ãã¹ãNavigationTask ...] ã ã€ãŸãããã¹ãŠã®ã¿ã¹ã¯ã¯ã«ãŒã¿ãŒã«ãã£ãŠé çªã«å®è¡ãããé çªã«å°ãããŠèªã¿ãããã¢ãããã¯ãšã³ãã£ãã£ãå®è¡ããŸãã
- æ§æã§è§£æ±ºã§ããªãæåŸã®ã¿ã¹ã¯ã¯æ®ããŸã-ããã¯çŸæç¹ã§ã®ã¢ããªã±ãŒã·ã§ã³ã®ç¶æ
ã§ãã ãŠãŒã¶ãŒãéšåçã«æž¡ãããããæ§æãã§ãŒã³å
šäœã§ã¯ãªãããã®äžéšã®ã¿ãæ§ç¯ããå¿
èŠãããå Žåã¯ã©ããªããŸããïŒ ãã®è³ªåã¯ããã¥ãŒã³ã³ãããŒã©ãŒã®ããªãŒã«ãã£ãŠåžžã«æ確ã«åçã§ããŸãã ãã§ãŒã³ã®äžéšããã§ã«æ§ç¯ãããŠããå Žåãããã¯ãã§ã«ããªãŒå
ã«ããããã§ãã ããã¯ããã§ãŒã³å
ã®åå·¥å Žã建èšãããŠãããã©ããã®è³ªåã«åçã§ããå Žåãã«ãŒã¿ãŒã¯ãã§ãŒã³ã®ã©ã®éšåãå®äºããå¿
èŠãããããç解ã§ããããšãæå³ããŸãã ãã¡ãããããã¯ãã¡ã¯ããªãŒã®ã¿ã¹ã¯ã§ã¯ãªããããå¥ã®ã¢ãããã¯ãšã³ãã£ãã£ãå°å
¥ãããŸã- æ€çŽ¢ãšã³ãžã³ïŒFinderïŒããã³æ§æã¯æ¬¡ã®ããã«ãªããŸãïŒ [Pre-navigation Task ...]-> ViewControllerã®éå§-> Action->ïŒFinder / Factory + [ContextTask ...]ïŒ -> ...->ïŒFinder / Factory + [ContextTask ...]ïŒ-> [Post NavigationTask ...] ã ã«ãŒã¿ãŒãæåŸããèªã¿åããéå§ãããšããã¡ã€ã³ããŒã®1ã€ãæ¢ã«æ§ç¯ãããŠããããšãéç¥ãããã®æç¹ããã«ãŒã¿ãŒã¯ãã§ãŒã³ã®æ§ç¯ãéå§ããŸãã ãããã®ãããããããªãŒã§èªåèªèº«ãèŠã€ããããªãå Žåãæåã®ã³ã³ãããŒã©ãŒãããã§ãŒã³å
šäœãæ§ç¯ããå¿
èŠããããŸãã
- æ§æã¯å³å¯ã«å ¥åããå¿ èŠããããŸãã ãããã£ãŠãåãšã³ãã£ãã£ã¯1çš®é¡ã®ã³ã³ãããŒã©ãŒãã¥ãŒã§ã®ã¿åäœããŸã; 1çš®é¡ã®ããŒã¿ãšèšå®ã¯ãswiftãrelatedtypesã䜿çšã§ãããã©ããã«å®å šã«äŸåããŠããŸãã ã©ã³ã¿ã€ã ã§ã¯ãªããã³ã³ãã€ã©ã«äŸåãããã®ã§ãã éçºè ã¯æå³çã«ã¿ã€ãã³ã°ã匱ããããšãã§ããŸããããã®éã¯ã§ããŸããã
ãã®ãããªæ§æã®äŸïŒ
let productScreen = StepAssembly(finder: ProductViewControllerFinder(), factory: ProductViewControllerFactory()) .add(LoginInterceptor<UUID>()) // Have to specify the context type till https://bugs.swift.org/browse/SR-8719 is fixed .add(ProductViewControllerContextTask()) .add(ProductViewControllerPostTask(analyticsManager: AnalyticsManager.sharedInstance)) .using(UINavigationController.push()) .from(NavigationControllerStep()) .using(GeneralActions.presentModally()) .from(GeneralStep.current()) .assemble()
äžèšã®é ç®ã¯ã©ã€ãã©ãªå šäœãç¶²çŸ ããã¢ãããŒãã説æããŠããŸãã æ®ã£ãŠããã®ã¯ããŠãŒã¶ãŒããã¿ã³ãã¯ãªãã¯ãããšãããŸãã¯å€éšã€ãã³ããçºçãããšãã«ã«ãŒã¿ãŒãå®è¡ãããã§ãŒã³æ§æãæäŸããããšã ãã§ãã ããããiPhoneãiPadãªã©ã®ç°ãªãã¿ã€ãã®ããã€ã¹ã§ããå Žåãããªã¢ãŒãã£ãºã ã䜿çšããŠç°ãªããã©ã³ãžã·ã§ã³æ§æãæäŸããŸãã A / Bãã¹ããããå Žåãåãããšã§ãã ããã²ãŒã·ã§ã³ãéå§ããæç¹ã§ã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãèæ ®ããå¿ èŠã¯ãããŸãããæåã«èšå®ãæ£ããèšè¿°ãããŠããããšã確èªããå¿ èŠããããã«ãŒã¿ãŒãäœããã®æ¹æ³ã§ãããæ§ç¯ããããšã確èªããŸãã
説æããã¢ãããŒãã¯ãç¹å®ã®æœè±¡åããã¿ãŒã³ãããè€éã§ããããŸã ååã§ã¯ãªããšããåé¡ã«çŽé¢ããŠããŸããã ãã¡ããã RouteComposerã«ã¯ããããã©ã®ããã«æ©èœãããã«ã€ããŠããçšåºŠã®èª¿æ»ãšç解ãå¿ èŠã§ãã ãã ããããã¯AutoLayoutãŸãã¯RunLoopã®åºæ¬ãåŠã¶ãããã¯ããã«ç°¡åã§ãã é«çæ°åŠã¯ãããŸããã
ã©ã€ãã©ãªãããã³ããã«æäŸãããã«ãŒã¿ãŒã®å®è£ ã¯ã客芳çãªã©ã³ã¿ã€ã ã§ããªãã¯ã䜿çšãããCocoa Touchã®ãã¹ãŠã®æŠå¿µã«å®å šã«æºæ ããæ§æããã»ã¹ãã¹ãããã«åå²ããæå®ãããé åºã§å®è¡ããã®ã«åœ¹ç«ã¡ãŸãã ã©ã€ãã©ãªã¯ãiOSããŒãžã§ã³9ã12ã§ãã¹ããããŠããŸãã
詳现ã«ã€ããŠã¯ã以åã®èšäºãã芧ãã ããã
UIViewControllersã®æ§æãšãããã®éã®ããã²ãŒã·ã§ã³ïŒã ãã§ãªãïŒ/ãªã¿ã¯èª
RouteComposer / geek magazineã䜿çšããUIViewControllersã®æ§æäŸ
ãæž èŽããããšãããããŸããã ã³ã¡ã³ãã§è³ªåã«ãçãããŸãã