You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Usually in an app, we have these flows: onboarding, login, main. And we usually set OnboardingController, LoginController and MainController as the root view controller respectively depending on the state.
I find it useful to have the MainController as the container for main flow. It can be a tab controller, swipe menu controller or contains just 1 child view controller. The screens are provided by child view controllers, but the MainController does the following jobs
Usually when app is brought to foreground, we need to fetch logged in user profile to see if there's changes. We do this by listening to app did become active in MainController.
Mock to open
This can be anti pattern. But in UI Tests, for laziness, we can just use some launch arguments and check to present some specific screens to test, because MainController is the root for main flow.
Logout
Because things originate from MainController, things can terminate in MainController. We can handle logout, clear states, and tell MainController to tell AppDelegate to switch to another root controller
The text was updated successfully, but these errors were encountered:
onmyway133
changed the title
The MainController
How to use MainController in iOS
May 12, 2019
Usually in an app, we have these flows: onboarding, login, main. And we usually set
OnboardingController
,LoginController
andMainController
as the root view controller respectively depending on the state.I find it useful to have the
MainController
as the container for main flow. It can be a tab controller, swipe menu controller or contains just 1 child view controller. The screens are provided by child view controllers, but theMainController
does the following jobsWe usually need to call
preferredStatusBarStyle
on the parent controller. See https://stackoverflow.com/questions/19022210/preferredstatusbarstyle-isnt-calledUsually when app is brought to foreground, we need to fetch logged in user profile to see if there's changes. We do this by listening to
app did become active
inMainController
.This can be anti pattern. But in UI Tests, for laziness, we can just use some launch arguments and check to present some specific screens to test, because
MainController
is the root for main flow.Because things originate from
MainController
, things can terminate inMainController
. We can handlelogout
, clear states, and tellMainController
to tellAppDelegate
to switch to another root controllerThe text was updated successfully, but these errors were encountered: