Skip to content

Instantly share code, notes, and snippets.

@Winchariot
Last active September 27, 2019 16:03
Show Gist options
  • Save Winchariot/4e61f64d3d8f12047babf47fdaa8a737 to your computer and use it in GitHub Desktop.
Save Winchariot/4e61f64d3d8f12047babf47fdaa8a737 to your computer and use it in GitHub Desktop.
3-phase app startup pattern
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
doPreUISetup()
doWindowSetup()
doPostUISetup()
return true
}
func doPreUISetup() {
//place code here that is required for app startup, especially anything the UI might rely on:
// setup/clear caches
// start logging
// etc.
}
func doWindowSetup() {
//create and set root VC, if doing so programmatically
}
func doPostUISetup() {
//place code here that doesn't rely on the UI:
// prefetching
// notification observer registration
// etc.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment