Swift - Execute code on LaunchScreen [duplicate] Swift - Execute code on LaunchScreen [duplicate] json json

Swift - Execute code on LaunchScreen [duplicate]


As you wrote, LaunchScreen is there before your app is ready and it implies that you can't execute your code in this time.

To achieve something similar, copy & paste content of your LaunchScreen into your initial view controller in your Main storyboard (or whatever you do use) and launch your request in initial view controller and then transition to any other view controller.

User is not going to notice LaunchScreen -> Main transition.

Purpose of LaunchScreen is to just replace splash images with something better where you can use auto layout for example, ... In other words, to minimize your work, so, you're not forced to create splash screen for every device screen size, etc. But you are not allowed to run any logic in LaunchScreen.


You can just place all your 'JSON code' inside your AppDelegate.swift under function 'didFinishLaunchingWithOptions'.