I have 4 viewControllers that all have different WKWebViews. When the user starts up the app and sees the first viewController, I want the WKWebViews of the other viewControllers to load in the background so that the app will seem more seamless when switching from viewController to viewController.
Is this possible? Or would I have to put all the webViews in one viewController?
Nearly all of the delay that you're trying to avoid is due to downloading the data; instantiating a web view once the data is available is fast enough that users won't notice any delay. Given that, what you should really be looking to do is to download the data, not instantiate more web views than you need. The question that BJHStudios suggested in a comment provides a couple options for this, but you should look at
NSURLSession
rather thanNSURLConnection
;NSURLSession
is very easy to use and offers a lot of flexibility. For example, you can configure a session to download data when the app is inactive.If your app makes use of a data model, you could incorporate the web resources required by each of the four view controllers into the model. When your app starts up, it would naturally instantiate the model, and the model would then retrieve the necessary resources so that they'd be immediately available for display when needed.