Last active
September 27, 2019 16:03
-
-
Save Winchariot/4e61f64d3d8f12047babf47fdaa8a737 to your computer and use it in GitHub Desktop.
3-phase app startup pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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